-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Timeline disappear when zooming #3782
Comments
@SectionSoutienAnalytique |
How did you fix the timeline flashing/disappearing? The suggestion from @rk9155 does not work for me using wavesurfer/react |
It does not work for me neither. I do not know if it's good but i do not see any problem with another plugin. There is my modification : //timeline.js
//line 94 add
this.subscriptions.push(this.wavesurfer.on('zoom', () => this.initTimeline()))
// delete line 146 to 174
private virtualAppend(start: number, container: HTMLElement, element: HTMLElement) {
let wasVisible = false
const renderIfVisible = (scrollLeft: number, scrollRight: number) => {
if (!this.wavesurfer) return
const width = element.clientWidth
const isVisible = start > scrollLeft && start + width < scrollRight
if (isVisible === wasVisible) return
wasVisible = isVisible
if (isVisible) {
container.appendChild(element)
} else {
element.remove()
}
}
setTimeout(() => {
if (!this.wavesurfer) return
renderIfVisible(0, this.wavesurfer?.getWidth() || 0)
this.subscriptions.push(
this.wavesurfer.on('scroll', (_start, _end, scrollLeft, scrollRight) => {
renderIfVisible(scrollLeft, scrollRight)
}),
)
}, 0)
}
//line 251 replace this.virtualAppend(offset, timeline, notch)
//display directly notch
timeline.appendChild(notch)
With this you can see result on the video |
I've looked into this a bit myself. This seems to happen when you zoom with a shifted cursor position. From what I can tell, the issue comes from the fact that the wave is reRendered on zoom which causes the timeline plugin to be reinitialized. It seems that the rerender adjusts the scroll window to account for the cursor position but the timeline assumes a 0 starting position and as a result the incorrect notches are rendered. A change like this fixes the issue without having to remove virtualAppend: //timeline.js
//Replace line 166: renderIfVisible(0, this.wavesurfer?.getWidth() || 0) with
const leftScroll = this.wavesurfer.getScroll()
const rightScroll = leftScroll + this.wavesurfer.getWidth()
renderIfVisible(leftScroll, rightScroll) This does seem to fix the issue on my end, however it does cause some flickering due to the deferred execution. Removing the timeout does solve the flickering issue, but I am unsure if this is safe to do. |
Uses current scroll position instead of 0 when initially rendering timeline. Previously, the initial render would show ticks starting from 0 regardless of scroll position. Closes katspaugh#3782
Bug description
In the Timeline plugin, when zooming in, the timeline disappears. It does not update correctly. However, as soon as the scrollbar is moved, the timeline updates properly.
Environment
Minimal code snippet
Expected result
GoodTimeline.mp4
Obtained result
BadTimeline.mp4
PR
I fix the issue (like you can see in the
Expected result
) but I do not know how to create PRThe text was updated successfully, but these errors were encountered: