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 277 forks source link

[Question] Suppress click in waveform #421

Closed rowild closed 2 years ago

rowild commented 2 years ago

Clicking into a waveform moves the playhead to the click position. Is there a way to suppress this functionality?

Background: The app consists of 2 steps:

Thank you!

UPDATE: I should add that it must still be possible to set markers via key strokes. Also, I currently assign a css class to the waveform container with "pointer-event: null". That works fine. However, I would love to know if there is a JS- or peaks-way. :-)

chrisn commented 2 years ago

Do you only want to disable the click to change playhead, or also disable click+drag to scroll the view?

rowild commented 2 years ago

Also click&drag should be disabled. (The user should not be allowed to interact at all with the waveform)

chrisn commented 2 years ago

Can you explain more about assigning CSS classes, I'm not sure I fully understand your question?

rowild commented 2 years ago

All I do is wrap a div around each view and add a respective css class:

<div class="[ zoomview-wrapper ]">
  <div id="zoomview" class="pointer-events-none"></div>
</div>

pointer-events-none is a tailwindcss class:

.pointer-events-none {
  pointer-events: none;
}

With JS I simply check the classList of a div:

// Either the waveform container directly:
const zoomview = document.getElementById('zoomview')
// or the wrapper element
const zoomview = document.querySelector('.zoomview-wrapper')
zoomview.classList.toggle('pointer-events-none')

I saw you added functions. Haven't checked them yet, but - THANK YOU!

chrisn commented 2 years ago

I just merged PR #424, happy to take any feedback. Maybe we don't need those functions, as setting the pointer-events in CSS also works!?

chrisn commented 2 years ago

I'll close this, given your feedback on #424. Thanks @rowild!