bbc / peaks.js

JavaScript UI component for interacting with audio waveforms
https://waveform.prototyping.bbc.co.uk
GNU Lesser General Public License v3.0
3.16k stars 275 forks source link

click event getting fired before dblclick event #495

Closed vivekd95 closed 1 year ago

vivekd95 commented 1 year ago

Hi @chrisn

I was wondering if both these events (zoomview.dblclick &zoomview.click) are getting fired at the same time correct or not. I meant when you double click on waveform via zoomview.dblclick, first zoomview.click gets fired. I think click and double click should be fired independently. Do share your point of view on this query and do correct me if I am brainstorming in the wrong direction.

chrisn commented 1 year ago

This isn't really specific to Peaks.js, for example, see the MDN docs for dblclick. Receiving both events is expected, and you'd have to, for example, set a timer to handle those events differently.

vivekd95 commented 1 year ago

So, is there any way to stop the auto-scrolling of the waveform when you click on the last second of the currently rendered view?

For my project, I wanted to add the functionality of creating a new segment by double-clicking on zoomview. Now, if I double-click around the end of the waveform (let's suppose 12 seconds are rendering in the current view and I double-click between the 11th and 12th seconds), the waveform is scrolling automatically, and I am not able to create the segment on the selected time stamp. It is getting created on another timestamp (12 plus the timestamp I clicked on).

I have attached a video to show my issue. As you can see, in the first rendered view, we can see approximately the first 12 seconds. When I double-clicked to create the segment, it jumped onto the next view, and my segment was created approximately at the 23rd second.

https://github.com/bbc/peaks.js/assets/107407402/a116689b-577b-4a84-9905-d15e4083f00d

chrisn commented 1 year ago

This is a separate topic to your original question, so I've moved this to a new issue.