简体   繁体   English

打动js自动播放幻灯片然后结束ID

[英]Impress js Auto-play Slideshow Then End On ID

I have a script to auto-play Impress JS, but I don't know how to end the slideshow on a certain ID or how to stop looping the slideshow once it ends. 我有一个脚本来自动播放Impress的JS,但我不知道该如何结束对某一ID或如何幻灯片停止循环播放幻灯片一旦结束。 Any help is appreciated. 任何帮助表示赞赏。

<script>
  var impress = impress();
  impress.init();
  document.addEventListener('impress:stepenter', function(e){
    if (typeof timing !== 'undefined') clearInterval(timing);
    var duration = (e.target.getAttribute('data-transition-duration') ? e.target.getAttribute('data-transition-duration') : 2000); // use the set duration or fallback to 2000ms
    timing = setInterval(impress.next, duration);
  });
</script>

setInterval() returns an interval ID, which you can pass to clearInterval(). setInterval()返回一个间隔ID,您可以将其传递给clearInterval()。 clearInterval is used to stop setInterval. clearInterval用于停止setInterval。

this should work: 这应该工作:

    if (currentSlide === 'the_ID_where_you_want_to_end') {
    clearInterval(timing);
    } 

change 更改

timing = setInterval(impress.next, duration);

with

if (e.target.id !== 'your_id') {
  timing = setInterval(impress.next, duration);  
}

and the presenter stops in your_id 演示者停在your_id

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM