Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

A small Reveal.js plugin to style slides based on the currently show fragment. Natively built into reveal.js from v3.9 onwards.

License

Notifications You must be signed in to change notification settings

boidolr/reveal.js-fragmentclasses

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

reveal.js-fragmentclasses

Reveal.js plugin to add a fragment class to the currently shown slide. By using that class additional styling can be triggered by stepping through fragments on a slide.

Installation

Copy this repository into the plugins folder of your reveal.js presentation, ie plugin/fragment.

Add the plugin to the dependencies in your presentation, as below.

Reveal.initialize({
    // ...
    dependencies: [
        // ...
        { src: 'plugin/fragment/fragment-classes.js' }
    ]
});

Usage

Add styles for your slides based on the activated fragments:

<body>
    <div class="reveal">
        <div class="slides">
            <section>
                <p>Already there</p>
                <p class="fragment">Appears first</p>
                <p class="fragment">Appears second</p>
                <p class="fragment">Appears last</p>
            </section>
            <style>
                .fragment-0 {
                    p { background: red; }
                }
                .present.fragment-1 {
                    p { background: blue; }
                }
            </style>
        </div>
    </div>
</body>

Configuration

You can customize the behaviour with className and onlyCurrentFragment parameters of your configuration.

Reveal.initialize({
    // ...
    fragmentclass: {
        // Base name to us for the classes - will be used as `fragment-0`, `fragment-1`, ...
        className: 'fragment',

        // Whether fragment classes should be removed if the fragment is no longer active
        onlyCurrentFragment: true
    }
});

License

MIT licensed.

Copyright (C) 2019 Raphael Boidol

About

A small Reveal.js plugin to style slides based on the currently show fragment. Natively built into reveal.js from v3.9 onwards.

Topics

Resources

License

Stars

Watchers

Forks