update logic for disabling fragments via config option
This commit is contained in:
parent
bff9bfb101
commit
4f280f77b0
|
@ -14,10 +14,10 @@ export default class Fragments {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows all fragments in the presentation. Used when
|
* If fragments are disabled in the deck, they should all be
|
||||||
* fragments are disabled presentation-wide.
|
* visible rather than stepped through.
|
||||||
*/
|
*/
|
||||||
showAll() {
|
disable() {
|
||||||
|
|
||||||
toArray( this.Reveal.getSlidesElement().querySelectorAll( '.fragment' ) ).forEach( element => {
|
toArray( this.Reveal.getSlidesElement().querySelectorAll( '.fragment' ) ).forEach( element => {
|
||||||
element.classList.add( 'visible' );
|
element.classList.add( 'visible' );
|
||||||
|
@ -26,6 +26,19 @@ export default class Fragments {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse of #disable(). Only called if fragments have
|
||||||
|
* previously been disabled.
|
||||||
|
*/
|
||||||
|
enable() {
|
||||||
|
|
||||||
|
toArray( this.Reveal.getSlidesElement().querySelectorAll( '.fragment' ) ).forEach( element => {
|
||||||
|
element.classList.remove( 'visible' );
|
||||||
|
element.classList.remove( 'current-fragment' );
|
||||||
|
} );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an object describing the available fragment
|
* Returns an object describing the available fragment
|
||||||
* directions.
|
* directions.
|
||||||
|
|
11
js/reveal.js
11
js/reveal.js
|
@ -787,7 +787,7 @@ export default function( revealElement, options ) {
|
||||||
*/
|
*/
|
||||||
function configure( options ) {
|
function configure( options ) {
|
||||||
|
|
||||||
const oldTransition = config.transition;
|
const oldConfig = { ...config }
|
||||||
|
|
||||||
// New config options may be passed when this method
|
// New config options may be passed when this method
|
||||||
// is invoked through the API after initialization
|
// is invoked through the API after initialization
|
||||||
|
@ -800,7 +800,7 @@ export default function( revealElement, options ) {
|
||||||
const numberOfSlides = dom.wrapper.querySelectorAll( SLIDES_SELECTOR ).length;
|
const numberOfSlides = dom.wrapper.querySelectorAll( SLIDES_SELECTOR ).length;
|
||||||
|
|
||||||
// The transition is added as a class on the .reveal element
|
// The transition is added as a class on the .reveal element
|
||||||
dom.wrapper.classList.remove( oldTransition );
|
dom.wrapper.classList.remove( oldConfig.transition );
|
||||||
dom.wrapper.classList.add( config.transition );
|
dom.wrapper.classList.add( config.transition );
|
||||||
|
|
||||||
dom.wrapper.setAttribute( 'data-transition-speed', config.transitionSpeed );
|
dom.wrapper.setAttribute( 'data-transition-speed', config.transitionSpeed );
|
||||||
|
@ -889,9 +889,12 @@ export default function( revealElement, options ) {
|
||||||
autoSlidePaused = false;
|
autoSlidePaused = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// When fragments are turned off they should be visible
|
// Update the state of our fragments
|
||||||
if( config.fragments === false ) {
|
if( config.fragments === false ) {
|
||||||
fragments.showAll();
|
fragments.disable();
|
||||||
|
}
|
||||||
|
else if( oldConfig.fragments === false ) {
|
||||||
|
fragments.enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the navigation mode to the DOM so we can adjust styling
|
// Add the navigation mode to the DOM so we can adjust styling
|
||||||
|
|
Loading…
Reference in New Issue
Block a user