execute function when certain slide appear in reveal.js

前端 未结 2 1721
旧时难觅i
旧时难觅i 2021-02-04 08:08

I create a presentation with this javascript framework http://lab.hakim.se/reveal-js/#/ and when certain slide is appearing I want to execute function stats(), which display som

2条回答
  •  有刺的猬
    2021-02-04 08:18

    This can be achieved by using reveal.js states (https://github.com/hakimel/reveal.js#states).

    1) Add a unique state to the section that should trigger your method.

    This will trigger a state event with the name "stats".

    2) Add a listener to your custom state using the reveal.js API.

    Reveal.addEventListener( 'stats', function() {
        // Called each time the slide with the "stats" state is made visible
    } );
    

    Complete working example: https://gist.github.com/hakimel/cea4305a33713d4a5a7e

提交回复
热议问题