简体   繁体   English

使用 slideNumber Reveal.js 检索当前幻灯片的编号

[英]Retrieve number of current slide using slideNumber Reveal.js

I need your help about Reveal.js.我需要你关于 Reveal.js 的帮助。

Anyone can explain me how to retrieve the number of my currentslide, and add it into variable ?任何人都可以解释我如何检索我的当前幻灯片的数量,并将其添加到变量中?

I need to add an event on my slide 4.我需要在幻灯片 4 上添加一个事件。

Thx for the support谢谢支持

You can get the indices of the current slide with Reveal.getIndices() .您可以使用Reveal.getIndices()获取当前幻灯片的索引。 It returns an object with three properties:它返回一个具有三个属性的对象:

  • h: horizontal index of the slide h:幻灯片的水平索引
  • v: vertical index of the slide v:幻灯片的垂直索引
  • f: Index of a fragment within the slide f:幻灯片中片段的索引

Now you can compare the current index with the index of the slide you want.现在您可以将当前索引与您想要的幻灯片索引进行比较。

Is this what you meant?这是你的意思吗?

Reveal.addEventListener('slidechanged', function(evt) {
  if (evt.currentSlide === 4) {
    // Do your stuff
  }
});

You can always store currentSlide somewhere and then retrieve it later if your action requires it to be done in the middle of the presentation, not on slidechanged .您始终可以将currentSlide存储在某处,然后如果您的操作需要在演示文稿中间而不是在slidechanged上完成,则稍后再检索它。

I do this to get the indice of the SLide:我这样做是为了获得幻灯片的索引:

 Reveal.addEventListener('slidechanged', function (evt) {
        ind = Reveal.getIndices().h
        if (ind === 0) {
            ......
        }
        if (ind === 1) {
            .....
        }
 });

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

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