Skip to content

Commit 840d1d8

Browse files
Rapsssitojeertmans
andauthored
fix(convert): avoid micro-stuttering with --one-file in HTML presentation (#508)
* fix: Fix micro-stuttering with --one-file in HTML presentation * Update template.html * Update CHANGELOG.md * Update CHANGELOG.md Co-authored-by: Jérome Eertmans <[email protected]> * Update CHANGELOG.md --------- Co-authored-by: Jérome Eertmans <[email protected]>
1 parent c15cd95 commit 840d1d8

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2222

2323
- Deprecate `-cdata_uri` in favor of `-cone_file` for `manim-slides convert`.
2424
[@Rapsssito](https://github.com/Rapsssito) [#505](https://github.com/jeertmans/manim-slides/pull/505)
25+
- Changed template to avoid micro-stuttering with `--one-file` in HTML presentation.
26+
[@Rapsssito](https://github.com/Rapsssito) [#508](https://github.com/jeertmans/manim-slides/pull/508)
2527

2628
(v5.2.0)=
2729
## [v5.2.0](https://github.com/jeertmans/manim-slides/compare/v5.1.10...v5.2.0)

docs/source/_static/template.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -316,15 +316,15 @@
316316
});
317317

318318
{% if one_file %}
319-
// Fix found by @t-fritsch on GitHub
320-
// see: https://github.com/hakimel/reveal.js/discussions/3362#discussioncomment-6651475.
319+
// Fix found by @t-fritsch and @Rapsssito on GitHub
320+
// see: https://github.com/hakimel/reveal.js/discussions/3362#discussioncomment-11733074.
321321
function fixBase64VideoBackground(event) {
322-
// event.previousSlide, event.currentSlide, event.indexh, event.indexv
323-
if (event.currentSlide.getAttribute('data-background-video')) {
324-
const background = Reveal.getSlideBackground(event.indexh, event.indexv),
325-
video = background.querySelector('video'),
326-
sources = video.querySelectorAll('source');
327-
322+
// Analyze all slides backgrounds
323+
for (const slide of Reveal.getBackgroundsElement().querySelectorAll('.slide-background')) {
324+
// Get the slide video and its sources for each background
325+
const video = slide.querySelector('video');
326+
const sources = video.querySelectorAll('source');
327+
// Update the source of the video
328328
sources.forEach((source, i) => {
329329
const src = source.getAttribute('src');
330330
if(src.match(/^data:video.*;base64$/)) {
@@ -334,8 +334,8 @@
334334
});
335335
}
336336
}
337+
// Setup base64 videos
337338
Reveal.on( 'ready', fixBase64VideoBackground );
338-
Reveal.on( 'slidechanged', fixBase64VideoBackground );
339339
{% endif %}
340340
</script>
341341

manim_slides/templates/revealjs.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -321,15 +321,15 @@
321321
});
322322

323323
{% if one_file -%}
324-
// Fix found by @t-fritsch on GitHub
325-
// see: https://github.com/hakimel/reveal.js/discussions/3362#discussioncomment-6651475.
324+
// Fix found by @t-fritsch and @Rapsssito on GitHub
325+
// see: https://github.com/hakimel/reveal.js/discussions/3362#discussioncomment-11733074.
326326
function fixBase64VideoBackground(event) {
327-
// event.previousSlide, event.currentSlide, event.indexh, event.indexv
328-
if (event.currentSlide.getAttribute('data-background-video')) {
329-
const background = Reveal.getSlideBackground(event.indexh, event.indexv),
330-
video = background.querySelector('video'),
331-
sources = video.querySelectorAll('source');
332-
327+
// Analyze all slides backgrounds
328+
for (const slide of Reveal.getBackgroundsElement().querySelectorAll('.slide-background')) {
329+
// Get the slide video and its sources for each background
330+
const video = slide.querySelector('video');
331+
const sources = video.querySelectorAll('source');
332+
// Update the source of the video
333333
sources.forEach((source, i) => {
334334
const src = source.getAttribute('src');
335335
if(src.match(/^data:video.*;base64$/)) {
@@ -339,8 +339,8 @@
339339
});
340340
}
341341
}
342+
// Setup base64 videos
342343
Reveal.on( 'ready', fixBase64VideoBackground );
343-
Reveal.on( 'slidechanged', fixBase64VideoBackground );
344344
{%- endif %}
345345
</script>
346346

0 commit comments

Comments
 (0)