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

avoid the initial jolt when starting to drag the panel #105

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,13 @@ Slideout.prototype._initTouchEvents = function() {

if (scrolling || self._preventOpen || typeof eve.touches === 'undefined') { return; }

var threshold = 20; //only start to move panel, when user drags for more than threshold pixels
var dif_x = eve.touches[0].clientX - self._startOffsetX;
var translateX = self._currentOffsetX = dif_x;

if (Math.abs(translateX) > self._padding) { return; }
if (Math.abs(translateX) > (self._padding + threshold)) { return; }

if (Math.abs(dif_x) > 20) {
if (Math.abs(dif_x) > threshold) {
self._opening = true;

var oriented_dif_x = dif_x * self._orientation;
Expand All @@ -234,6 +235,9 @@ Slideout.prototype._initTouchEvents = function() {
self._opening = false;
}

var translateX_sign = translateX < 0 ? -1 : 1
translateX = translateX - (threshold * translateX_sign);

if (!self._moved && html.className.search('slideout-open') === -1) {
html.className += ' slideout-open';
}
Expand Down