I'm trying to prevent interruptions of easeTo animation, so I disable map interactions when run easeTo and enable them back when animation ends.
Disable interactions:
map.easeTo( options, { isAnimation: true } )
map.boxZoom.disable();
map.scrollZoom.disable();
map.dragPan.disable();
map.dragRotate.disable();
map.keyboard.disable();
map.doubleClickZoom.disable();
map.touchZoomRotate.disable();
Enable interactions:
map.on( 'moveend', e => {
if (e.isAnimation) {
map.boxZoom.enable();
map.scrollZoom.enable();
map.dragPan.enable();
map.dragRotate.enable();
map.keyboard.enable();
map.doubleClickZoom.enable();
map.touchZoomRotate.enable();
}
})
However this works differently depending on interactive flag set on map creation.
If set interactive: false, map behaves as expected: it stops interactions when animation starts and enable them back when animation ends.
if set interactive: true, manually disabled interactions still can interrupt animation and moveend event will be fired before animation has reached the end point.
Thanks for the report @VadimDubovoy .
@vakila One more reason to refactor input handlers.
Just looking at bind_handlers.js and indeed it seems like we don't really care about the handlers' enabled/disabled state but rather rely on options.interactive to decide whether or not to stop the animation. We should definitely still look into refactoring handlers overall, but for now I think we can fix this with some extra checks in there. Self-assigning this as part of the other UI stuff I'm working on.
This has been fixed by https://github.com/mapbox/mapbox-gl-js/pull/9365. If you have a chance to test and confirm, that would be great! The fix is in master and will be released in a beta release tomorrow.