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

Added a threshold of 3 pixels before initiating drag. #210

Merged
merged 1 commit into from
Jul 17, 2015
Merged
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
19 changes: 15 additions & 4 deletions src/sly.js
Original file line number Diff line number Diff line change
Expand Up @@ -1429,11 +1429,22 @@

if (!dragging.released && dragging.path < 1) return;

// We haven't decided whether this is a drag or not...
if (!dragging.init) {
if (o.horizontal ? abs(dragging.pathX) > abs(dragging.pathY) : abs(dragging.pathX) < abs(dragging.pathY)) {
dragging.init = 1;
} else {
return dragEnd();
// If the drag path was very short, maybe it's not a drag?
if (dragging.path < 3) {
// If the pointer was released, the path will not become longer and it's
// definitely not a drag. If not released yet, decide on next iteration
return dragging.released ? dragEnd() : undefined;
}
else {
// If dragging path is sufficiently long we can confidently start a drag
// if drag is in different direction than scroll, ignore it
if (o.horizontal ? abs(dragging.pathX) > abs(dragging.pathY) : abs(dragging.pathX) < abs(dragging.pathY)) {
dragging.init = 1;
} else {
return dragEnd();
}
}
}

Expand Down