Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confine scroll area #35

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
</script>
```
Expand Down Expand Up @@ -165,7 +166,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
});
</script>

Expand Down Expand Up @@ -193,13 +195,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
});
```

Expand Down
7 changes: 5 additions & 2 deletions dist/slideout.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/slideout.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
});

Expand Down
3 changes: 2 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ describe('Slideout', function () {
'_fx',
'_duration',
'_tolerance',
'_padding'
'_padding',
'_fromedge'
];
var i = 0;
var len = properties.length;
Expand Down