Avoid Reload of a slide to go to the first slide #504
-
Hi, I use animated GIFs in Marp slide. When i want to play the GIF again while presenting, i need to use Ctrl-R in the browser to reload the slide. It has a strange effect to first go to the first slide before returning to the current one reloaded :-) Is there a way to avoid this unwanted step. Thanks ! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Marp's HTML slide is one simple HTML file, so if you request a full page reload, you cannot avoid the first page being briefly displayed until the assets for each slide have finished loading. Therefore, it would be more efficient to reload only the specific GIF image, to restart the animations from the beginning. In exported HTML slide, writing a script like the following allows you to click on a GIF image to reload it, prompting a replay. (Allow using HTML tags and scripts on Marp tools you are using. Depending on the browser's cache situation, there may be cases where the replay does not occur). 
<script>
<!--
document.addEventListener('click', (e) => {
const gifImage = e.target.closest('img[src*=".gif"]');
if (gifImage) gifImage.src = gifImage.src;
});
-->
</script> Note For many years, browsers have not provided a clear way to control the playback of animated GIFs. If you need to control playback of animation, it is recommended to use the <video src="animation.mp4" muted autoplay playsinline loop controls> |
Beta Was this translation helpful? Give feedback.
Marp's HTML slide is one simple HTML file, so if you request a full page reload, you cannot avoid the first page being briefly displayed until the assets for each slide have finished loading.
Therefore, it would be more efficient to reload only the specific GIF image, to restart the animations from the beginning. In exported HTML slide, writing a script like the following allows you to click on a GIF image to reload it, prompting a replay. (Allow using HTML tags and scripts on Marp tools you are using. Depending on the browser's cache situation, there may be cases where the replay does not occur).