chartjs-plugin-zoom icon indicating copy to clipboard operation
chartjs-plugin-zoom copied to clipboard

OnZoomComplete callback final event to call a local method

Open sarabjeet1313 opened this issue 3 years ago • 3 comments

Hi,

Currently, we get lots of onZoomComplete() callbacks even with a single mouse wheel scroll. We need to call a local method after the user done with the actual zoom completion.

Is there any way we can detect once when all the mouse wheel events are done so that we can call our local method after the zoom?

sarabjeet1313 avatar Sep 15 '22 15:09 sarabjeet1313

onZoomComplete is already debounced at 250ms. (I would love to see an option to configure or disable that debouncing.) If you are seeing multiple calls to onZoomComplete you will need to add your own debouncing with a greater timeout

I ended up ignoring onZoomComplete and putting a debounced function call in onZoom which gave me the control I needed.

` const debounced = _.debounce(yourFunction, 500);

onZoom: () => { debounced(); } `

thejoecode avatar Sep 20 '22 17:09 thejoecode

Is there any way we can detect once when all the mouse wheel events are done so that we can call our local method after the zoom?

No, user could go to have a coffee at the next city and come back after 4 hours to continuing zooming 😃

But maybe the hardcoded 250ms can be exposed as an option, so you can configure it to suit the actual use case better. Would that help?

kurkle avatar Nov 23 '22 21:11 kurkle

Exposing the debounce time with an option to disable it completely would be great. Maybe 0 and or null instead of a number to disable.

thejoecode avatar Dec 13 '22 03:12 thejoecode