自动滑动

¥Auto-Slide

可以将演示文稿配置为自动逐页播放幻灯片,无需任何用户输入。要启用此功能,你需要使用 autoSlide 配置选项指定幻灯片切换的间隔。间隔以毫秒为单位。

¥Presentations can be configured to step through slides automatically, without any user input. To enable this you will need to specify an interval for slide changes using the autoSlide config option. The interval is provided in milliseconds.

// Slide every five seconds
Reveal.initialize({
  autoSlide: 5000,
  loop: true,
});
Slide 1
Slide 2
Slide 3

自动滑动幻灯片时,播放/暂停控制元素将自动显示。如果用户开始与幻灯片组交互,滑动将自动暂停。也可以通过按键盘上的“A”键暂停或恢复滑动(此处嵌入的演示中不起作用)。

¥A play/pause control element will automatically appear for auto-sliding decks. Sliding is automatically paused if the user starts interacting with the deck. It's also possible to pause or resume sliding by pressing »A« on the keyboard (won't work in the embedded demo here).

你可以通过在 配置选项 中指定 autoSlideStoppable: false 来禁用自动幻灯片控件并防止滑动暂停。

¥You can disable the auto-slide controls and prevent sliding from being paused by specifying autoSlideStoppable: false in your config options.

幻灯片时间

¥Slide Timing

它还可以使用 data-autoslide 属性覆盖单个幻灯片和片段的幻灯片时长。

¥It's also possible to override the slide duration for individual slides and fragments by using the data-autoslide attribute.

<section data-autoslide="2000">
  <p>After 2 seconds the first fragment will be shown.</p>
  <p class="fragment" data-autoslide="10000">
    After 10 seconds the next fragment will be shown.
  </p>
  <p class="fragment">
    Now, the fragment is displayed for 2 seconds before the next slide is shown.
  </p>
</section>

自动滑动方法

¥Auto-Slide Method

autoSlideMethod 配置选项可用于覆盖自动滑动时用于导航的默认函数。

¥The autoSlideMethod config option can be used to override the default function used for navigation when auto-sliding.

默认情况下,我们单步浏览所有幻灯片,包括水平幻灯片和 vertical 幻灯片。要仅沿顶层导航并忽略垂直幻灯片,你可以提供一个调用 Reveal.right() 的方法。

¥We step through all slides, both horizontal and vertical, by default. To only navigate along the top layer and ignore vertical slides, you can provide a method that calls Reveal.right().

Reveal.configure({
  autoSlideMethod: () => Reveal.right(),
});

活动

¥Events

每当自动滑动暂停或恢复时,我们都会触发事件。

¥We fire events whenever auto-sliding is paused or resumed.

Reveal.on('autoslideresumed', (event) => {
  /* ... */
});
Reveal.on('autoslidepaused', (event) => {
  /* ... */
});