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

Map zoom fires "movestart" many times, but "moveend" only once #8256

Closed
bambielli-flex opened this issue May 16, 2019 · 7 comments · Fixed by #8259
Closed

Map zoom fires "movestart" many times, but "moveend" only once #8256

bambielli-flex opened this issue May 16, 2019 · 7 comments · Fixed by #8259

Comments

@bambielli-flex
Copy link
Contributor

bambielli-flex commented May 16, 2019

I'm not sure if this is a bug, but it was unexpected behavior to me.

I'm attaching event listeners to movestart and moveend.

I'm finding that while dragging / panning the map, the event listeners trigger when I would expect them to trigger (when user starts moving the map movestart fires, then when they release the map moveend fires)

However while zooming it looks like movestart is firing many many times while moveend is still only firing once.

This seems somewhat related to #6512, but with the zoom api instead of resize.

mapbox-gl-js version:
0.53.1
browser:
Chrome

Steps to Trigger Behavior

  1. attach map.on('movestart', () =>{}) and map.on('moveend', () => {}) event listeners.
  2. zoom the map in or out.

Link to Demonstration

https://jsfiddle.net/bambielli767/Lc5yutef/9/

Expected Behavior

movestart and moveend are both triggered once, when zooming starts and when zooming finishes.

Actual Behavior

movestart is triggered many many times, while moveend is still only triggered once.

@mourner
Copy link
Member

mourner commented May 16, 2019

This definitely looks like a bug. Thanks for the report! Might have regressed in recent versions.

@bambielli-flex
Copy link
Contributor Author

No prob. If you think the fix is simple enough for a first timer of the project, I'd be happy to look in to it.

@ryanhamley
Copy link
Contributor

ryanhamley commented May 16, 2019

This doesn't appear to be a recent regression. I tested back to v0.35.0 and observed this behavior.

The event is being fired here. zoomstart and zoomend exhibit the same behavior. movestart and zoomstart are duplicating the move and zoom events. I'm not sure the best way to fix this off the top of my head, but marker.js uses an internal state to track whether or not a dragstart or drag event should be fired so something like that might work well for this. It shouldn't be too bad if you want to submit a PR @bambielli-flex

@bambielli-flex
Copy link
Contributor Author

I'll take a look!

@mourner
Copy link
Member

mourner commented May 17, 2019

@ryanhamley it definitely used to work before. So far I traced this back to somewhere between v0.14 (working fine) and v0.15 (buggy). Which apparently means this is the first known occurrence of someone depending on that event in 3+ years 😆

@Eh2406
Copy link

Eh2406 commented Jul 24, 2019

@mourner I did not realize this was a bug and just filtered it out in my code.

@vpmammana
Copy link

I am observing this only on the real android. When I test it on a desktop webbrowser emulating an android, the problem doesn't show up. The problem is intermitent. Some times zoom triggers moveend, sometime it doesn't.

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

Successfully merging a pull request may close this issue.

5 participants