mapbox-gl-directions
mapbox-gl-directions copied to clipboard
Debounce `fetchDirections` to prevent firing handlers while dragging markers

This behaviour is still there, don't know if it's still the same underlying cause as #36
@xivk I just came across the same behavior and @anandthakker helped me understand what's going on there. It seems like we generate events while dragging markers instead of waiting until we're done with dragging here
https://github.com/mapbox/mapbox-gl-directions/blob/46cd036bcce32ac1b6d6db0ae63de5cadb6b40c5/src/actions/index.js#L53
There should be a check for the dragging behavior here
https://github.com/mapbox/mapbox-gl-directions/blob/02e3145560978d3fc6990c0831ed097099fdba36/src/directions.js#L289
but it seems like it's not working.
Thanks for having a look!
I'll try and figure out why the check is not working but I'm not sure if I will be able to fix this myself in way that's acceptable (as in pull-request)...
I had the same issue when dragging custom markers and how I fixed this was during drag I had to set the style.transform to none.
drag: function (e) {
$(this.hint)[0].style.transform = "none";
}
For our drag and drop we use Kendo UI so the "hint" above is a clone of the marker.
Playing with the transform setting in your drag method may be worth a shot.