How to get last wheel event in Cesium?

I have a problem with wheel event. I want to fetch some data after scroll wheel, but when I do as below:

var handler = new Cesium.ScreenSpaceEventHandler(viewer.canvas);

handler.setInputAction(function (e) {
}, Cesium.ScreenSpaceEventType.WHEEL);


The result is that the fetchData function will be invoked several times. I want it just call one time after the last wheel event triggered, rather than send useless request in the wheeling process.

Any ideas?


That’s not how scrolling works, there is no “last event”. The same is true for mouse move and any other events that requires interactivity. This isn’t Cesium specific and is just how the browser works (and most other mouse systems).

If you just want to be notified once when the camera is done moving, look at the camera.moveStart/moveEnd properties. But this is for all camera movement and not just the wheel. If you really only care about when the wheel event is finished, then you need to set a timer and only make your request after a small amount of time has gone by without the event being fired.

That’s true, the scrolling event works like that. I am just curious if anyway we can detect the end of wheeling.
Thank you very much, and I will work on the timer approach.