Skip to content

Add dragmode: false #3170

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

Merged
merged 6 commits into from
Nov 9, 2018
Merged
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
Prev Previous commit
Next Next commit
allow mouse/touch events to pass through when dragmode is false
  • Loading branch information
jonfunkhouser committed Oct 26, 2018
commit 4f3270ec6b6883eea5285752b218ea9a897d7f77
20 changes: 12 additions & 8 deletions src/components/dragelement/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ dragElement.init = function init(options) {
var clampFn = options.clampFn || _clampFn;

function onStart(e) {
e.preventDefault();

// make dragging and dragged into properties of gd
// so that others can look at and modify them
gd._dragged = false;
Expand Down Expand Up @@ -167,11 +165,15 @@ dragElement.init = function init(options) {
document.documentElement.style.cursor = window.getComputedStyle(element).cursor;
}

document.addEventListener('mousemove', onMove);
document.addEventListener('mouseup', onDone);
document.addEventListener('touchmove', onMove);
document.addEventListener('touchend', onDone);

if(options.dragmode !== false) {
e.preventDefault();
document.addEventListener('mousemove', onMove);
document.addEventListener('touchmove', onMove);
}

return;
}

Expand All @@ -195,13 +197,15 @@ dragElement.init = function init(options) {
}

function onDone(e) {
document.removeEventListener('mousemove', onMove);
if(options.dragmode !== false) {
e.preventDefault();
document.removeEventListener('mousemove', onMove);
document.removeEventListener('touchmove', onMove);
}

document.removeEventListener('mouseup', onDone);
document.removeEventListener('touchmove', onMove);
document.removeEventListener('touchend', onDone);

e.preventDefault();

if(hasHover) {
Lib.removeElement(dragCover);
}
Expand Down