maplibre-gl-js icon indicating copy to clipboard operation
maplibre-gl-js copied to clipboard

Zooming by mouse/touchpad is disabled/really lagging while animating the center of the map from the JS API

Open hodossy opened this issue 2 years ago • 6 comments

maplibre-gl-js version: 2.1.9

browser: Chrome

Steps to Trigger Behavior

  1. Set up an animation that uses requestAnimationFrame to set the center of the map with either setCenter, easeTo or panTo
  2. Try to change the zoom of the map

Link to Demonstration

https://jsfiddle.net/jr23t5wy/3/

based on https://maplibre.org/maplibre-gl-js-docs/example/animate-point-along-line/

Expected Behavior

Zoom is not affected by any means by the calls to setCenter

Actual Behavior

It seams that those two are not independent, therefore frequent calls to setCenter effectively disables manual zoom.

Remark: My goal is to create a (sort of) navigation app, so the point is to have a marker indicating a car (ego vehicle) with a symbol layer and geojson source and keeping the car in the middle of the map. I update the car location (== the Point feature) and the center of the map at 60 FPS.

hodossy avatar Apr 28 '22 11:04 hodossy

I think I had a similar issue I encountered recently with animating the map to indicate the north when using the device compass. Can you check if this happens with mapbox version 1.0? I think this issue was introduced between 1.0 and 1.2.

HarelM avatar Apr 28 '22 11:04 HarelM

Here you go: https://jsfiddle.net/jr23t5wy/4/

It is better there, zoom is responsive, but while I zoom, the center is not set as I would expect. It seems like setCenter is ignored during zoom.

hodossy avatar Apr 28 '22 11:04 hodossy

This makes sense as when you zoom you "freeze" the center around the zoom. Helping find the commit that introduced this issue would help a lot as we can better understand maybe where the code to fix this...

HarelM avatar Apr 28 '22 15:04 HarelM

I am not too familiar with the code base, but I can try to find the first release where this went wrong.

hodossy avatar Apr 29 '22 06:04 hodossy

Sorry for the delay, I was not able to find the time to check upon this until now. The last working version is 1.9.1 (jsFiddle), and the first version that has this issue is 1.10.0 (jsFiddle)

hodossy avatar May 11 '22 14:05 hodossy

I'm guessing there's not many file changes between those releases, and even less are about touch and gestures I guess. Finding and understanding the code that changed should be possible for you, I hope.

HarelM avatar May 11 '22 16:05 HarelM