Skip to content

Mute event listener logging #2251

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 3 commits into from
Jan 18, 2018
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion src/components/dragelement/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ dragElement.init = function init(options) {
element.style.pointerEvents = 'all';

element.onmousedown = onStart;
element.ontouchstart = onStart;

if(element._ontouchstart) {
element.removeEventListener('touchstart', element._ontouchstart);
}
element._ontouchstart = onStart;
element.addEventListener('touchstart', onStart, {passive: false});

function onStart(e) {
// make dragging and dragged into properties of gd
Expand Down
11 changes: 8 additions & 3 deletions src/plots/cartesian/dragbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,9 +434,14 @@ module.exports = function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {

// everything but the corners gets wheel zoom
if(ns.length * ew.length !== 1) {
// still seems to be some confusion about onwheel vs onmousewheel...
if(dragger.onwheel !== undefined) dragger.onwheel = zoomWheel;
else if(dragger.onmousewheel !== undefined) dragger.onmousewheel = zoomWheel;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep that onmousewheel handler in case we need it in older browsers?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the only difference between what @dfcreative has here and what we had before is that now we always attach to either wheel or mousewheel, whereas before we could potentially attach to neither if the browser doesn't support either one (I had to play with this - you may already know this but what's going on is if the browser supports wheel, then element.onwheel = null before any handler is attached, not undefined). And even if there is a case where the browser really doesn't support either, there shouldn't be any problem attaching to a nonexistent event.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see. My bad. 👌

var wheelEventName = dragger.onwheel !== undefined ? 'wheel' : 'mousewheel';

if(dragger._onwheel) {
dragger.removeEventListener(wheelEventName, dragger._onwheel);
}
dragger._onwheel = zoomWheel;

dragger.addEventListener(wheelEventName, zoomWheel, {passive: false});
}

// plotDrag: move the plot in response to a drag
Expand Down