Mapbox-gl-js: Disabled interactions still interrupt easeTo animations

Created on 4 Sep 2019  路  3Comments  路  Source: mapbox/mapbox-gl-js

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.

https://jsfiddle.net/8sajomqv/

bug

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings