Skip to content
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

Feat: render canvases on scroll #3700

Merged
merged 3 commits into from
May 11, 2024
Merged

Feat: render canvases on scroll #3700

merged 3 commits into from
May 11, 2024

Conversation

katspaugh
Copy link
Owner

@katspaugh katspaugh commented May 11, 2024

Short description

Resolves #3696

Instead of rendering the entire waveform asynchronously chunk by chunk, render only the chunks that are in the viewport.

Implementation details

We subscribe to the scroll event and render the parts of the waveform that are currently visible. If the number of canvases exceeds 100, we clear the old canvases.

How to test it

It can be tested with this example: https://wavesurfer.xyz/examples/?d5da9feca7995cd70caabe1ce6ec18d4

Breaking API changes

The redrawcomplete event was previously emitted when all canvases finish rendering. Now it will be emitted after the initial 2 canvases are rendered.

Copy link

cloudflare-pages bot commented May 11, 2024

Deploying wavesurfer-js with  Cloudflare Pages  Cloudflare Pages

Latest commit: 841a489
Status: ✅  Deploy successful!
Preview URL: https://f52b7a5e.wavesurfer-js.pages.dev
Branch Preview URL: https://render-on-scroll.wavesurfer-js.pages.dev

View logs

@katspaugh katspaugh merged commit 22d61c9 into main May 11, 2024
4 checks passed
@katspaugh katspaugh deleted the render-on-scroll branch May 11, 2024 16:16
katspaugh added a commit that referenced this pull request May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant