We've come across situations where want to perform some application logic once the map is done doing its thing.
We've tried using onInteractionStateChange and creating a shouldUpdateApp variable which checks if every interactionState properties are false.
<ReactMapGl
...
onInteractionStateChange={(interactionState) => {
const shouldUpateApp = Object.keys(interactionState).every((key) => !interactionState(key))
if (shouldUpdateApp) {
updateApp()
}
}}
/>
This works great except for _onWheel. Because _onWheel is considered an one-off event, our updateApp() gets called on each instance of wheel. This isn't ideal as we only care about the app being updated once we are idle.
Mapbox supports the 'idle' event.
It would be great if we could support the 'idle' event by passing in an onIdle prop similar to onLoad and onError.
We can probably add a debounce to resetting isZooming on wheel events. That should solve your issue?
Debouncing would solve my issue!
However, that fix seems less appropriate than handling the behavior through the 'idle' event.
Is there a particular reason we want to avoid supporting the 'idle' event?
idle refers to both a change in the interaction state (managed by react-map-gl) and data loading/rendering (managed by mapbox-gl). I'm open to supporting it in the long term but it will be more complicated to implement and test.
The debounced state is published (4.1.8 and 5.0.4).
Most helpful comment
idlerefers to both a change in the interaction state (managed by react-map-gl) and data loading/rendering (managed by mapbox-gl). I'm open to supporting it in the long term but it will be more complicated to implement and test.