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 1 commit
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
Next Next commit
avoid the initial 'jolt' when starting to drag the panel. this was du…
…e to the 20px threshold when deciding whether the user intended to drag the panel
  • Loading branch information
benfreu committed Jul 29, 2015
commit 6e1139542e9f64ed478f26d1d7e6ed6832747485
10 changes: 8 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,18 @@ Slideout.prototype._initTouchEvents = function() {
*/
this.panel.addEventListener(touch.move, function(eve) {

var threshold = 20; //only start to move panel, when user drags for more than threshold pixels

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

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) > threshold) {
var translateX_sign = translateX < 0 ? -1 : 1

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

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

translateX = translateX - (threshold * translateX_sign);

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