npm.io
0.1.0 • Published 3 years ago

reveal.js-script-fragment

Licence
MIT
Version
0.1.0
Deps
2
Size
8 kB
Vulns
1
Weekly
0

reveal.js-animate-fragments

A Reveal.js plugin to execute a Javascript script as a fragment.

Installation

npm install reveal.js-script-fragment

Usage

Add the plugin:

<script type="module">
  import RevealScriptFragment from "reveal.js-script-fragment";

  import Reveal from "reveal.js";

  let deck = new Reveal({
    plugins: [RevealScriptFragment ],
  });
  deck.initialize();
</script>

And then add a fragment script like this:

<section>
  <span class="fragment">This is a fragment!</span>

  <script-fragment>
    <script data-on-show type="text/template">
      console.log('This will print when this fragment is shown');
    </script>
    <script data-on-hide type="text/template">
      console.log('This will print when this fragment is hidden');
    </script>
  </script-fragment>

</section>

Both scripts types data-on-show and data-on-hide are optional.