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

zoom Behavior, dblclick does not provide an event #2411

Closed
langdonx opened this issue Apr 30, 2015 · 1 comment
Closed

zoom Behavior, dblclick does not provide an event #2411

langdonx opened this issue Apr 30, 2015 · 1 comment

Comments

@langdonx
Copy link

Was removing the event on dblclick in the Zoom behavior intentional here?

60df296#diff-8a5d2f6d536a2448e970d4de069dc30a

I've been on 3.4.8 for a while, but just upgraded to 3.5.5. My code was checking d3.event.sourceEvent and doing something based on the type, but the sourceEvent is null now when double click is used as opposed to mouse wheel.

// causes Uncaught TypeError: Cannot read property 'type' of null
if (wheelEvent.type === 'wheel' || wheelEvent.type === 'mousewheel') {
@langdonx langdonx changed the title zoom Behavior zoom Behavior, dblclick does not provide an event Apr 30, 2015
@mbostock
Copy link
Member

Yes. The sourceEvent went away because the double-click now triggers a zoom transition rather than an immediate zoom. (And I don’t believe it makes sense for these delayed events to have a source event, given the source event happened in the past. All other source events occur within the lifecycle of the source event, so that you can, for example, prevent default behaviors.)

You can still listen to dblclick events yourself, optionally with capture, and stop propagation to prevent the zoom behavior from responding to them.

I’m not sure what exactly you’re trying to do, but feel free to reply if you have more questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants