maplibre / maplibre-gl-directions

A plugin to show routing directions on a MapLibre GL JS map
https://maplibre.org/maplibre-gl-directions/
MIT License
72 stars 16 forks source link

Map frozen on touchscreens after calling destroy() #186

Closed clementmas closed 1 year ago

clementmas commented 1 year ago

On a touchscreen device, if you drag the the line or a vertex, then remove the directions (call destroy()), it will freeze the map and it won't pan anymore.

Here's the reproduction link: https://codesandbox.io/s/maplibre-gl-directions-pan-error-s1giw7

I think this has to do with with line: https://github.com/maplibre/maplibre-gl-directions/blob/main/src/directions/main.ts#L483

Disable the global onMove handlers for them not to interfere with the new ones which are added further down.

Somehow it stays disabled and creates this bug.

smellyshovel commented 1 year ago

Thanks for the reproduction. Can confirm the bug, but only if you call destroy without manually panning the map after adding a waypoint. If you add a waypoint, then pan the map, then destroy directions, then everything's fine for some reason. I'll try to check it out once I have time.

clementmas commented 1 year ago

Indeed. The issue only happens if the map isn't moved after creating or dragging a waypoint.

I temporarily fixed it on my app by manually calling map.dragPan.enable() after destroy().

smellyshovel commented 1 year ago

@clementmas do you still have the issue? For some reason I can't reproduce it anymore even using the same attached repro from the OP :confused:

smellyshovel commented 1 year ago

No, now it's back. Strange...

clementmas commented 1 year ago

It only happens if the touchstart event is triggered. So the devtools responsive mode needs to simulate a touchscreen device. Then the issue is there.