From d84bae2d33b4544cd44034d1c87fcdaec9fd4e10 Mon Sep 17 00:00:00 2001 From: Daan de Graaf Date: Mon, 16 Mar 2015 18:36:24 +0100 Subject: [PATCH 1/2] Implement 'fromedge' option and behaviour --- README.md | 7 +++++-- dist/slideout.js | 7 +++++-- dist/slideout.min.js | 2 +- index.js | 5 ++++- test/test.js | 3 ++- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 681928a..6c89876 100644 --- a/README.md +++ b/README.md @@ -165,7 +165,8 @@ Then you just include Slideout.js and create a new instace with some options: 'panel': document.getElementById('panel'), 'menu': document.getElementById('menu'), 'padding': 256, - 'tolerance': 70 + 'tolerance': 70, + 'fromedge': true }); @@ -193,13 +194,15 @@ Create a new instance of `Slideout`. - `[options.fx]` (String) - The CSS effect to use when animating the opening and closing of the slideout. Default: `ease`. - `[options.padding]` (Number) - Default: `256`. - `[options.tolerance]` (Number) - Default: `70`. +- `[options.fromedge]` (Boolean) - Slide the panel only if the touch started on the left 33% of the screen. Default: true. ```js var slideout = new Slideout({ 'panel': document.getElementById('main'), 'menu': document.getElementById('menu'), 'padding': 256, - 'tolerance': 70 + 'tolerance': 70, + 'fromedge': true }); ``` diff --git a/dist/slideout.js b/dist/slideout.js index cd07074..d75fccd 100644 --- a/dist/slideout.js +++ b/dist/slideout.js @@ -62,6 +62,7 @@ function Slideout(options) { this._duration = parseInt(options.duration, 10) || 300; this._tolerance = parseInt(options.tolerance, 10) || 70; this._padding = parseInt(options.padding, 10) || 256; + this._fromedge = options.fromedge || typeof options.fromedge == 'undefined'; // Init touch events this._initTouchEvents(); @@ -159,9 +160,11 @@ Slideout.prototype._initTouchEvents = function() { * Resets values on touchstart */ this.panel.addEventListener(touch.start, function(eve) { + var off_x = eve.touches[0].pageX; + if(self._fromedge && !self.isOpen() && off_x > screen.width/3){ self._preventOpen = true; return; } self._moved = false; self._opening = false; - self._startOffsetX = eve.touches[0].pageX; + self._startOffsetX = off_x; self._preventOpen = (!self.isOp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IGRlY291cGxlO1xuIl19 diff --git a/dist/slideout.min.js b/dist/slideout.min.js index 2d668c3..d781223 100644 --- a/dist/slideout.min.js +++ b/dist/slideout.min.js @@ -1 +1 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.Slideout=e()}}(function(){var e,t,n;return function i(e,t,n){function s(r,a){if(!t[r]){if(!e[r]){var f=typeof require=="function"&&require;if(!a&&f)return f(r,!0);if(o)return o(r,!0);var u=new Error("Cannot find module '"+r+"'");throw u.code="MODULE_NOT_FOUND",u}var l=t[r]={exports:{}};e[r][0].call(l.exports,function(t){var n=e[r][1][t];return s(n?n:t)},l,l.exports,i,e,t,n)}return t[r].exports}var o=typeof require=="function"&&require;for(var r=0;re._tolerance?e.open():e.close()}e._moved=false});this.panel.addEventListener(u.move,function(t){if(o||e._preventOpen){return}var n=t.touches[0].clientX-e._startOffsetX;var i=e._currentOffsetX=n;if(Math.abs(i)>e._padding){return}if(Math.abs(n)>20){e._opening=true;if(e._opened&&n>0||!e._opened&&n<0){return}if(!e._moved&&a.className.search("slideout-open")===-1){a.className+=" slideout-open"}if(n<=0){i=n+e._padding;e._opening=false}e.panel.style[l+"transform"]=e.panel.style.transform="translate3d("+i+"px, 0, 0)";e._moved=true}})};t.exports=p},{decouple:2}],2:[function(e,t,n){"use strict";var i=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||function(e){window.setTimeout(e,1e3/60)}}();function s(e,t,n){var s,o=false;function r(e){s=e;a()}function a(){if(!o){i(f);o=true}}function f(){n.call(e,s);o=false}e.addEventListener(t,r,false)}t.exports=s},{}]},{},[1])(1)}); \ No newline at end of file +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.Slideout=e()}}(function(){var e,t,n;return function i(e,t,n){function s(r,a){if(!t[r]){if(!e[r]){var f=typeof require=="function"&&require;if(!a&&f)return f(r,!0);if(o)return o(r,!0);var u=new Error("Cannot find module '"+r+"'");throw u.code="MODULE_NOT_FOUND",u}var l=t[r]={exports:{}};e[r][0].call(l.exports,function(t){var n=e[r][1][t];return s(n?n:t)},l,l.exports,i,e,t,n)}return t[r].exports}var o=typeof require=="function"&&require;for(var r=0;rscreen.width/3){e._preventOpen=true;return}e._moved=false;e._opening=false;e._startOffsetX=n;e._preventOpen=!e.isOpen()&&e.menu.clientWidth!==0});this.panel.addEventListener("touchcancel",function(){e._moved=false;e._opening=false});this.panel.addEventListener(u.end,function(){if(e._moved){e._opening&&Math.abs(e._currentOffsetX)>e._tolerance?e.open():e.close()}e._moved=false});this.panel.addEventListener(u.move,function(t){if(o||e._preventOpen){return}var n=t.touches[0].clientX-e._startOffsetX;var i=e._currentOffsetX=n;if(Math.abs(i)>e._padding){return}if(Math.abs(n)>20){e._opening=true;if(e._opened&&n>0||!e._opened&&n<0){return}if(!e._moved&&a.className.search("slideout-open")===-1){a.className+=" slideout-open"}if(n<=0){i=n+e._padding;e._opening=false}e.panel.style[l+"transform"]=e.panel.style.transform="translate3d("+i+"px, 0, 0)";e._moved=true}})};t.exports=p},{decouple:2}],2:[function(e,t,n){"use strict";var i=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||function(e){window.setTimeout(e,1e3/60)}}();function s(e,t,n){var s,o=false;function r(e){s=e;a()}function a(){if(!o){i(f);o=true}}function f(){n.call(e,s);o=false}e.addEventListener(t,r,false)}t.exports=s},{}]},{},[1])(1)}); \ No newline at end of file diff --git a/index.js b/index.js index e8eba40..bed0a19 100644 --- a/index.js +++ b/index.js @@ -61,6 +61,7 @@ function Slideout(options) { this._duration = parseInt(options.duration, 10) || 300; this._tolerance = parseInt(options.tolerance, 10) || 70; this._padding = parseInt(options.padding, 10) || 256; + this._fromedge = options.fromedge || typeof options.fromedge == 'undefined'; // Init touch events this._initTouchEvents(); @@ -158,9 +159,11 @@ Slideout.prototype._initTouchEvents = function() { * Resets values on touchstart */ this.panel.addEventListener(touch.start, function(eve) { + var off_x = eve.touches[0].pageX; + if(self._fromedge && !self.isOpen() && off_x > screen.width/3){ self._preventOpen = true; return; } self._moved = false; self._opening = false; - self._startOffsetX = eve.touches[0].pageX; + self._startOffsetX = off_x; self._preventOpen = (!self.isOpen() && self.menu.clientWidth !== 0); }); diff --git a/test/test.js b/test/test.js index e48c632..02a0aa9 100644 --- a/test/test.js +++ b/test/test.js @@ -53,7 +53,8 @@ describe('Slideout', function () { '_fx', '_duration', '_tolerance', - '_padding' + '_padding', + '_fromedge' ]; var i = 0; var len = properties.length; From 085899719b3c1396b05ae95e2a1257f3b666ab43 Mon Sep 17 00:00:00 2001 From: Daan de Graaf Date: Mon, 16 Mar 2015 19:08:49 +0100 Subject: [PATCH 2/2] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6c89876..7fc7298 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,8 @@ Then you just include Slideout.js and create a new instace with some options: 'panel': document.getElementById('panel'), 'menu': document.getElementById('menu'), 'padding': 256, - 'tolerance': 70 + 'tolerance': 70, + 'fromedge': true }); ``` @@ -194,7 +195,7 @@ Create a new instance of `Slideout`. - `[options.fx]` (String) - The CSS effect to use when animating the opening and closing of the slideout. Default: `ease`. - `[options.padding]` (Number) - Default: `256`. - `[options.tolerance]` (Number) - Default: `70`. -- `[options.fromedge]` (Boolean) - Slide the panel only if the touch started on the left 33% of the screen. Default: true. +- `[options.fromedge]` (Boolean) - Slide the panel only if the touch started on the left 33% of the screen. Default: `true`. ```js var slideout = new Slideout({