Skip to content

Commit f64680a

Browse files
committed
Cut pauseEvent wrapper
1 parent 05ded3c commit f64680a

File tree

3 files changed

+11
-19
lines changed

3 files changed

+11
-19
lines changed

src/components/dragelement/index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ dragElement.init = function init(options) {
164164
document.addEventListener('touchmove', onMove);
165165
document.addEventListener('touchend', onDone);
166166

167-
return Lib.pauseEvent(e);
167+
e.preventDefault();
168+
return;
168169
}
169170

170171
function onMove(e) {
@@ -181,7 +182,8 @@ dragElement.init = function init(options) {
181182

182183
if(gd._dragged && options.moveFn && !rightClick) options.moveFn(dx, dy);
183184

184-
return Lib.pauseEvent(e);
185+
e.preventDefault();
186+
return;
185187
}
186188

187189
function onDone(e) {
@@ -246,7 +248,8 @@ dragElement.init = function init(options) {
246248

247249
gd._dragged = false;
248250

249-
return Lib.pauseEvent(e);
251+
e.preventDefault();
252+
return;
250253
}
251254
};
252255

src/lib/index.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -150,20 +150,6 @@ lib.swapAttrs = function(cont, attrList, part1, part2) {
150150
}
151151
};
152152

153-
/**
154-
* to prevent event bubbling, in particular text selection during drag.
155-
* see http://stackoverflow.com/questions/5429827/
156-
* how-can-i-prevent-text-element-selection-with-cursor-drag
157-
* for maximum effect use:
158-
* return pauseEvent(e);
159-
*/
160-
lib.pauseEvent = function(e) {
161-
if(e.stopPropagation) e.stopPropagation();
162-
if(e.preventDefault) e.preventDefault();
163-
e.cancelBubble = true;
164-
return false;
165-
};
166-
167153
/**
168154
* SVG painter's algo worked around with reinsertion
169155
*/

src/plots/cartesian/dragbox.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,9 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
360360

361361
// If a transition is in progress, then disable any behavior:
362362
if(gd._transitioningWithDuration) {
363-
return Lib.pauseEvent(e);
363+
e.preventDefault();
364+
e.stopPropagation();
365+
return;
364366
}
365367

366368
var pc = gd.querySelector('.plotly');
@@ -434,7 +436,8 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
434436
dragTail(zoomMode);
435437
}, REDRAWDELAY);
436438

437-
return Lib.pauseEvent(e);
439+
e.preventDefault();
440+
return;
438441
}
439442

440443
// everything but the corners gets wheel zoom

0 commit comments

Comments
 (0)