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 event listeners are passed an incorrect sourceEvent if a programmatic zoom occurs during a user zoom gesture #253

Open
yurivish opened this issue Jun 24, 2022 · 0 comments

Comments

@yurivish
Copy link

yurivish commented Jun 24, 2022

Programmatic zoom intiated while the user is making a gesture causes the zoom callback to be invoked with the sourceEvent from the preceding user action, rather than an undefined sourceEvent.

I think this is because there is an active Gesture on the element and the following line does not update the event to null or undefined:

if (event) this.sourceEvent = event;

which is called indirectly from

https://github.com/d3/d3-zoom/blob/main/src/zoom.js#L85

with an undefined event.


Example: https://observablehq.com/d/11402b3301150892 (see console for stack overflow)

The example notebook tries to perform a programmatic zoom once for every user-initiated zoom, but because the programmatic zoomed callback is invoked with a trusted sourceEvent, this results in infinite recursion.

First noticed here (which now implements a workaround)

@yurivish yurivish changed the title Programmatic zoom transforms have a trusted sourceEvent if initiated during a zoom gesture Programmatic zoom transforms are passed an incorrect sourceEvent if initiated during a zoom gesture Jun 24, 2022
@yurivish yurivish changed the title Programmatic zoom transforms are passed an incorrect sourceEvent if initiated during a zoom gesture Zoom event listeners are passed an incorrect sourceEvent if programmatic zoom is initiated during a user's zoom gesture Jun 24, 2022
@yurivish yurivish changed the title Zoom event listeners are passed an incorrect sourceEvent if programmatic zoom is initiated during a user's zoom gesture Zoom event listeners are passed an incorrect sourceEvent if a programmatic zoom occurs during a user zoom gesture Jun 24, 2022
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

1 participant