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

Function wheelZoom dispatches the 'zoom' event too early #74

Open
burgrmikulas opened this issue Jul 9, 2020 · 1 comment
Open

Function wheelZoom dispatches the 'zoom' event too early #74

burgrmikulas opened this issue Jul 9, 2020 · 1 comment

Comments

@burgrmikulas
Copy link

The 'zoom' event is being dispatched by the wheelZoom function before the actual zooming happens. I would like to hook to this event and be able to read the new viewport to adjust other elements in the SVG (my use case is keeping vector-effect-like stroke of a line, i.e. same pixels width whatever zoom level I am in).

If dispatching this event cannot be done later, I suggest dispatching another event (e.g. 'afterZoom') at the very end of this function. This is the workaround I have put in place and seems to be working perfectly.

Many thanks for any suggestions/actions on this.

@Fuzzyma
Copy link
Member

Fuzzyma commented Jul 9, 2020

That might be useful. What I did, was just using setTimeout(fn, 0) in the zoom event to make the zoom happen first and run my code afterwards but I see that a seperate event might be cleaner. The reason the event comes first is because it is cancelable. So you actually can prevent the zoom from happening.

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

No branches or pull requests

2 participants