ox-reveal update
This commit is contained in:
@@ -73,8 +73,8 @@ export default {
|
||||
|
||||
// Optional function that blocks keyboard events when retuning false
|
||||
//
|
||||
// If you set this to 'foucsed', we will only capture keyboard events
|
||||
// for embdedded decks when they are in focus
|
||||
// If you set this to 'focused', we will only capture keyboard events
|
||||
// for embedded decks when they are in focus
|
||||
keyboardCondition: null,
|
||||
|
||||
// Disables the default reveal.js slide layout (scaling and centering)
|
||||
@@ -149,7 +149,7 @@ export default {
|
||||
// Flags if slides with data-visibility="hidden" should be kep visible
|
||||
showHiddenSlides: false,
|
||||
|
||||
// Global override for autolaying embedded media (video/audio/iframe)
|
||||
// Global override for autoplaying embedded media (video/audio/iframe)
|
||||
// - null: Media will only autoplay if data-autoplay is present
|
||||
// - true: All media will autoplay, regardless of individual setting
|
||||
// - false: No media will autoplay, regardless of individual setting
|
||||
|
||||
@@ -27,8 +27,16 @@ export default class AutoAnimate {
|
||||
// Clean up after prior animations
|
||||
this.reset();
|
||||
|
||||
// Ensure that both slides are auto-animate targets
|
||||
if( fromSlide.hasAttribute( 'data-auto-animate' ) && toSlide.hasAttribute( 'data-auto-animate' ) ) {
|
||||
let allSlides = this.Reveal.getSlides();
|
||||
let toSlideIndex = allSlides.indexOf( toSlide );
|
||||
let fromSlideIndex = allSlides.indexOf( fromSlide );
|
||||
|
||||
// Ensure that both slides are auto-animate targets with the same data-auto-animate-id value
|
||||
// (including null if absent on both) and that data-auto-animate-restart isn't set on the
|
||||
// physically latter slide (independent of slide direction)
|
||||
if( fromSlide.hasAttribute( 'data-auto-animate' ) && toSlide.hasAttribute( 'data-auto-animate' )
|
||||
&& fromSlide.getAttribute( 'data-auto-animate-id' ) === toSlide.getAttribute( 'data-auto-animate-id' )
|
||||
&& !( toSlideIndex > fromSlideIndex ? toSlide : fromSlide ).hasAttribute( 'data-auto-animate-restart' ) ) {
|
||||
|
||||
// Create a new auto-animate sheet
|
||||
this.autoAnimateStyleSheet = this.autoAnimateStyleSheet || createStyleSheet();
|
||||
@@ -40,8 +48,7 @@ export default class AutoAnimate {
|
||||
toSlide.dataset.autoAnimate = 'pending';
|
||||
|
||||
// Flag the navigation direction, needed for fragment buildup
|
||||
let allSlides = this.Reveal.getSlides();
|
||||
animationOptions.slideDirection = allSlides.indexOf( toSlide ) > allSlides.indexOf( fromSlide ) ? 'forward' : 'backward';
|
||||
animationOptions.slideDirection = toSlideIndex > fromSlideIndex ? 'forward' : 'backward';
|
||||
|
||||
// Inject our auto-animate styles for this transition
|
||||
let css = this.getAutoAnimatableElements( fromSlide, toSlide ).map( elements => {
|
||||
|
||||
@@ -27,8 +27,6 @@ export default class Backgrounds {
|
||||
*/
|
||||
create() {
|
||||
|
||||
let printMode = this.Reveal.isPrintingPDF();
|
||||
|
||||
// Clear prior backgrounds
|
||||
this.element.innerHTML = '';
|
||||
this.element.classList.add( 'no-transition' );
|
||||
@@ -114,9 +112,24 @@ export default class Backgrounds {
|
||||
*/
|
||||
sync( slide ) {
|
||||
|
||||
let element = slide.slideBackgroundElement,
|
||||
const element = slide.slideBackgroundElement,
|
||||
contentElement = slide.slideBackgroundContentElement;
|
||||
|
||||
const data = {
|
||||
background: slide.getAttribute( 'data-background' ),
|
||||
backgroundSize: slide.getAttribute( 'data-background-size' ),
|
||||
backgroundImage: slide.getAttribute( 'data-background-image' ),
|
||||
backgroundVideo: slide.getAttribute( 'data-background-video' ),
|
||||
backgroundIframe: slide.getAttribute( 'data-background-iframe' ),
|
||||
backgroundColor: slide.getAttribute( 'data-background-color' ),
|
||||
backgroundRepeat: slide.getAttribute( 'data-background-repeat' ),
|
||||
backgroundPosition: slide.getAttribute( 'data-background-position' ),
|
||||
backgroundTransition: slide.getAttribute( 'data-background-transition' ),
|
||||
backgroundOpacity: slide.getAttribute( 'data-background-opacity' ),
|
||||
};
|
||||
|
||||
const dataPreload = slide.hasAttribute( 'data-preload' );
|
||||
|
||||
// Reset the prior background state in case this is not the
|
||||
// initial sync
|
||||
slide.classList.remove( 'has-dark-background' );
|
||||
@@ -135,19 +148,6 @@ export default class Backgrounds {
|
||||
contentElement.style.opacity = '';
|
||||
contentElement.innerHTML = '';
|
||||
|
||||
let data = {
|
||||
background: slide.getAttribute( 'data-background' ),
|
||||
backgroundSize: slide.getAttribute( 'data-background-size' ),
|
||||
backgroundImage: slide.getAttribute( 'data-background-image' ),
|
||||
backgroundVideo: slide.getAttribute( 'data-background-video' ),
|
||||
backgroundIframe: slide.getAttribute( 'data-background-iframe' ),
|
||||
backgroundColor: slide.getAttribute( 'data-background-color' ),
|
||||
backgroundRepeat: slide.getAttribute( 'data-background-repeat' ),
|
||||
backgroundPosition: slide.getAttribute( 'data-background-position' ),
|
||||
backgroundTransition: slide.getAttribute( 'data-background-transition' ),
|
||||
backgroundOpacity: slide.getAttribute( 'data-background-opacity' )
|
||||
};
|
||||
|
||||
if( data.background ) {
|
||||
// Auto-wrap image urls in url(...)
|
||||
if( /^(http|file|\/\/)/gi.test( data.background ) || /\.(svg|png|jpg|jpeg|gif|bmp)([?#\s]|$)/gi.test( data.background ) ) {
|
||||
@@ -179,7 +179,7 @@ export default class Backgrounds {
|
||||
if( data.backgroundColor ) element.style.backgroundColor = data.backgroundColor;
|
||||
if( data.backgroundTransition ) element.setAttribute( 'data-background-transition', data.backgroundTransition );
|
||||
|
||||
if( slide.hasAttribute( 'data-preload' ) ) element.setAttribute( 'data-preload', '' );
|
||||
if( dataPreload ) element.setAttribute( 'data-preload', '' );
|
||||
|
||||
// Background image options are set on the content wrapper
|
||||
if( data.backgroundSize ) contentElement.style.backgroundSize = data.backgroundSize;
|
||||
@@ -192,8 +192,8 @@ export default class Backgrounds {
|
||||
// color, no class will be added
|
||||
let contrastColor = data.backgroundColor;
|
||||
|
||||
// If no bg color was found, check the computed background
|
||||
if( !contrastColor ) {
|
||||
// If no bg color was found, or it cannot be converted by colorToRgb, check the computed background
|
||||
if( !contrastColor || !colorToRgb( contrastColor ) ) {
|
||||
let computedBackgroundStyle = window.getComputedStyle( element );
|
||||
if( computedBackgroundStyle && computedBackgroundStyle.backgroundColor ) {
|
||||
contrastColor = computedBackgroundStyle.backgroundColor;
|
||||
@@ -201,7 +201,7 @@ export default class Backgrounds {
|
||||
}
|
||||
|
||||
if( contrastColor ) {
|
||||
let rgb = colorToRgb( contrastColor );
|
||||
const rgb = colorToRgb( contrastColor );
|
||||
|
||||
// Ignore fully transparent backgrounds. Some browsers return
|
||||
// rgba(0,0,0,0) when reading the computed background color of
|
||||
@@ -394,4 +394,10 @@ export default class Backgrounds {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
destroy() {
|
||||
|
||||
this.element.remove();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
7
scripts/reveal.js/js/controllers/controls.js
vendored
7
scripts/reveal.js/js/controllers/controls.js
vendored
@@ -188,6 +188,13 @@ export default class Controls {
|
||||
}
|
||||
}
|
||||
|
||||
destroy() {
|
||||
|
||||
this.unbind();
|
||||
this.element.remove();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Event handlers for navigation control buttons.
|
||||
*/
|
||||
|
||||
@@ -79,6 +79,12 @@ export default class Focus {
|
||||
|
||||
}
|
||||
|
||||
destroy() {
|
||||
|
||||
this.Reveal.getRevealElement().classList.remove( 'focused' );
|
||||
|
||||
}
|
||||
|
||||
onRevealPointerDown( event ) {
|
||||
|
||||
this.focus();
|
||||
|
||||
@@ -235,6 +235,7 @@ export default class Fragments {
|
||||
el.classList.remove( 'current-fragment' );
|
||||
|
||||
if( wasVisible ) {
|
||||
this.Reveal.slideContent.stopEmbeddedContent( el );
|
||||
changedFragments.hidden.push( el );
|
||||
this.Reveal.dispatchEvent({
|
||||
target: el,
|
||||
|
||||
@@ -32,15 +32,15 @@ export default class Keyboard {
|
||||
}
|
||||
else {
|
||||
this.shortcuts['N , SPACE'] = 'Next slide';
|
||||
this.shortcuts['P'] = 'Previous slide';
|
||||
this.shortcuts['P , Shift SPACE'] = 'Previous slide';
|
||||
this.shortcuts['← , H'] = 'Navigate left';
|
||||
this.shortcuts['→ , L'] = 'Navigate right';
|
||||
this.shortcuts['↑ , K'] = 'Navigate up';
|
||||
this.shortcuts['↓ , J'] = 'Navigate down';
|
||||
}
|
||||
|
||||
this.shortcuts['Home , Shift ←'] = 'First slide';
|
||||
this.shortcuts['End , Shift →'] = 'Last slide';
|
||||
this.shortcuts['Alt + ←/↑/→/↓'] = 'Navigate without fragments';
|
||||
this.shortcuts['Shift + ←/↑/→/↓'] = 'Jump to first/last slide';
|
||||
this.shortcuts['B , .'] = 'Pause';
|
||||
this.shortcuts['F'] = 'Fullscreen';
|
||||
this.shortcuts['ESC, O'] = 'Slide overview';
|
||||
@@ -182,13 +182,11 @@ export default class Keyboard {
|
||||
let activeElementIsInput = document.activeElement && document.activeElement.tagName && /input|textarea/i.test( document.activeElement.tagName );
|
||||
let activeElementIsNotes = document.activeElement && document.activeElement.className && /speaker-notes/i.test( document.activeElement.className);
|
||||
|
||||
// Whitelist specific modified + keycode combinations
|
||||
let prevSlideShortcut = event.shiftKey && event.keyCode === 32;
|
||||
let firstSlideShortcut = event.shiftKey && keyCode === 37;
|
||||
let lastSlideShortcut = event.shiftKey && keyCode === 39;
|
||||
// Whitelist certain modifiers for slide navigation shortcuts
|
||||
let isNavigationKey = [32, 37, 38, 39, 40, 78, 80].indexOf( event.keyCode ) !== -1;
|
||||
|
||||
// Prevent all other events when a modifier is pressed
|
||||
let unusedModifier = !prevSlideShortcut && !firstSlideShortcut && !lastSlideShortcut &&
|
||||
let unusedModifier = !( isNavigationKey && event.shiftKey || event.altKey ) &&
|
||||
( event.shiftKey || event.altKey || event.ctrlKey || event.metaKey );
|
||||
|
||||
// Disregard the event if there's a focused element or a
|
||||
@@ -277,52 +275,58 @@ export default class Keyboard {
|
||||
|
||||
// P, PAGE UP
|
||||
if( keyCode === 80 || keyCode === 33 ) {
|
||||
this.Reveal.prev();
|
||||
this.Reveal.prev({skipFragments: event.altKey});
|
||||
}
|
||||
// N, PAGE DOWN
|
||||
else if( keyCode === 78 || keyCode === 34 ) {
|
||||
this.Reveal.next();
|
||||
this.Reveal.next({skipFragments: event.altKey});
|
||||
}
|
||||
// H, LEFT
|
||||
else if( keyCode === 72 || keyCode === 37 ) {
|
||||
if( firstSlideShortcut ) {
|
||||
if( event.shiftKey ) {
|
||||
this.Reveal.slide( 0 );
|
||||
}
|
||||
else if( !this.Reveal.overview.isActive() && useLinearMode ) {
|
||||
this.Reveal.prev();
|
||||
this.Reveal.prev({skipFragments: event.altKey});
|
||||
}
|
||||
else {
|
||||
this.Reveal.left();
|
||||
this.Reveal.left({skipFragments: event.altKey});
|
||||
}
|
||||
}
|
||||
// L, RIGHT
|
||||
else if( keyCode === 76 || keyCode === 39 ) {
|
||||
if( lastSlideShortcut ) {
|
||||
this.Reveal.slide( Number.MAX_VALUE );
|
||||
if( event.shiftKey ) {
|
||||
this.Reveal.slide( this.Reveal.getHorizontalSlides().length - 1 );
|
||||
}
|
||||
else if( !this.Reveal.overview.isActive() && useLinearMode ) {
|
||||
this.Reveal.next();
|
||||
this.Reveal.next({skipFragments: event.altKey});
|
||||
}
|
||||
else {
|
||||
this.Reveal.right();
|
||||
this.Reveal.right({skipFragments: event.altKey});
|
||||
}
|
||||
}
|
||||
// K, UP
|
||||
else if( keyCode === 75 || keyCode === 38 ) {
|
||||
if( !this.Reveal.overview.isActive() && useLinearMode ) {
|
||||
this.Reveal.prev();
|
||||
if( event.shiftKey ) {
|
||||
this.Reveal.slide( undefined, 0 );
|
||||
}
|
||||
else if( !this.Reveal.overview.isActive() && useLinearMode ) {
|
||||
this.Reveal.prev({skipFragments: event.altKey});
|
||||
}
|
||||
else {
|
||||
this.Reveal.up();
|
||||
this.Reveal.up({skipFragments: event.altKey});
|
||||
}
|
||||
}
|
||||
// J, DOWN
|
||||
else if( keyCode === 74 || keyCode === 40 ) {
|
||||
if( !this.Reveal.overview.isActive() && useLinearMode ) {
|
||||
this.Reveal.next();
|
||||
if( event.shiftKey ) {
|
||||
this.Reveal.slide( undefined, Number.MAX_VALUE );
|
||||
}
|
||||
else if( !this.Reveal.overview.isActive() && useLinearMode ) {
|
||||
this.Reveal.next({skipFragments: event.altKey});
|
||||
}
|
||||
else {
|
||||
this.Reveal.down();
|
||||
this.Reveal.down({skipFragments: event.altKey});
|
||||
}
|
||||
}
|
||||
// HOME
|
||||
@@ -331,7 +335,7 @@ export default class Keyboard {
|
||||
}
|
||||
// END
|
||||
else if( keyCode === 35 ) {
|
||||
this.Reveal.slide( Number.MAX_VALUE );
|
||||
this.Reveal.slide( this.Reveal.getHorizontalSlides().length - 1 );
|
||||
}
|
||||
// SPACE
|
||||
else if( keyCode === 32 ) {
|
||||
@@ -339,10 +343,10 @@ export default class Keyboard {
|
||||
this.Reveal.overview.deactivate();
|
||||
}
|
||||
if( event.shiftKey ) {
|
||||
this.Reveal.prev();
|
||||
this.Reveal.prev({skipFragments: event.altKey});
|
||||
}
|
||||
else {
|
||||
this.Reveal.next();
|
||||
this.Reveal.next({skipFragments: event.altKey});
|
||||
}
|
||||
}
|
||||
// TWO-SPOT, SEMICOLON, B, V, PERIOD, LOGITECH PRESENTER TOOLS "BLACK SCREEN" BUTTON
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
*/
|
||||
export default class Location {
|
||||
|
||||
// The minimum number of milliseconds that must pass between
|
||||
// calls to history.replaceState
|
||||
MAX_REPLACE_STATE_FREQUENCY = 1000
|
||||
|
||||
constructor( Reveal ) {
|
||||
|
||||
this.Reveal = Reveal;
|
||||
@@ -10,6 +14,8 @@ export default class Location {
|
||||
// Delays updates to the URL due to a Chrome thumbnailer bug
|
||||
this.writeURLTimeout = 0;
|
||||
|
||||
this.replaceStateTimestamp = 0;
|
||||
|
||||
this.onWindowHashChange = this.onWindowHashChange.bind( this );
|
||||
|
||||
}
|
||||
@@ -27,19 +33,18 @@ export default class Location {
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the current URL (hash) and navigates accordingly.
|
||||
* Returns the slide indices for the given hash link.
|
||||
*
|
||||
* @param {string} [hash] the hash string that we want to
|
||||
* find the indices for
|
||||
*
|
||||
* @returns slide indices or null
|
||||
*/
|
||||
readURL() {
|
||||
|
||||
let config = this.Reveal.getConfig();
|
||||
let indices = this.Reveal.getIndices();
|
||||
let currentSlide = this.Reveal.getCurrentSlide();
|
||||
|
||||
let hash = window.location.hash;
|
||||
getIndicesFromHash( hash=window.location.hash ) {
|
||||
|
||||
// Attempt to parse the hash as either an index or name
|
||||
let bits = hash.slice( 2 ).split( '/' ),
|
||||
name = hash.replace( /#\/?/gi, '' );
|
||||
let name = hash.replace( /^#\/?/, '' );
|
||||
let bits = name.split( '/' );
|
||||
|
||||
// If the first bit is not fully numeric and there is a name we
|
||||
// can assume that this is a named link
|
||||
@@ -61,23 +66,12 @@ export default class Location {
|
||||
}
|
||||
catch ( error ) { }
|
||||
|
||||
// Ensure that we're not already on a slide with the same name
|
||||
let isSameNameAsCurrentSlide = currentSlide ? currentSlide.getAttribute( 'id' ) === name : false;
|
||||
|
||||
if( element ) {
|
||||
// If the slide exists and is not the current slide...
|
||||
if ( !isSameNameAsCurrentSlide || typeof f !== 'undefined' ) {
|
||||
// ...find the position of the named slide and navigate to it
|
||||
let slideIndices = this.Reveal.getIndices( element );
|
||||
this.Reveal.slide( slideIndices.h, slideIndices.v, f );
|
||||
}
|
||||
}
|
||||
// If the slide doesn't exist, navigate to the current slide
|
||||
else {
|
||||
this.Reveal.slide( indices.h || 0, indices.v || 0 );
|
||||
return { ...this.Reveal.getIndices( element ), f };
|
||||
}
|
||||
}
|
||||
else {
|
||||
const config = this.Reveal.getConfig();
|
||||
let hashIndexBase = config.hashOneBasedIndex ? 1 : 0;
|
||||
|
||||
// Read the index components of the hash
|
||||
@@ -92,10 +86,32 @@ export default class Location {
|
||||
}
|
||||
}
|
||||
|
||||
if( h !== indices.h || v !== indices.v || f !== undefined ) {
|
||||
this.Reveal.slide( h, v, f );
|
||||
return { h, v, f };
|
||||
}
|
||||
|
||||
// The hash couldn't be parsed or no matching named link was found
|
||||
return null
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the current URL (hash) and navigates accordingly.
|
||||
*/
|
||||
readURL() {
|
||||
|
||||
const currentIndices = this.Reveal.getIndices();
|
||||
const newIndices = this.getIndicesFromHash();
|
||||
|
||||
if( newIndices ) {
|
||||
if( ( newIndices.h !== currentIndices.h || newIndices.v !== currentIndices.v || newIndices.f !== undefined ) ) {
|
||||
this.Reveal.slide( newIndices.h, newIndices.v, newIndices.f );
|
||||
}
|
||||
}
|
||||
// If no new indices are available, we're trying to navigate to
|
||||
// a slide hash that does not exist
|
||||
else {
|
||||
this.Reveal.slide( currentIndices.h || 0, currentIndices.v || 0 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -132,10 +148,10 @@ export default class Location {
|
||||
else if( config.hash ) {
|
||||
// If the hash is empty, don't add it to the URL
|
||||
if( hash === '/' ) {
|
||||
window.history.replaceState( null, null, window.location.pathname + window.location.search );
|
||||
this.debouncedReplaceState( window.location.pathname + window.location.search );
|
||||
}
|
||||
else {
|
||||
window.history.replaceState( null, null, '#' + hash );
|
||||
this.debouncedReplaceState( '#' + hash );
|
||||
}
|
||||
}
|
||||
// UPDATE: The below nuking of all hash changes breaks
|
||||
@@ -153,6 +169,26 @@ export default class Location {
|
||||
|
||||
}
|
||||
|
||||
replaceState( url ) {
|
||||
|
||||
window.history.replaceState( null, null, url );
|
||||
this.replaceStateTimestamp = Date.now();
|
||||
|
||||
}
|
||||
|
||||
debouncedReplaceState( url ) {
|
||||
|
||||
clearTimeout( this.replaceStateTimeout );
|
||||
|
||||
if( Date.now() - this.replaceStateTimestamp > this.MAX_REPLACE_STATE_FREQUENCY ) {
|
||||
this.replaceState( url );
|
||||
}
|
||||
else {
|
||||
this.replaceStateTimeout = setTimeout( () => this.replaceState( url ), this.MAX_REPLACE_STATE_FREQUENCY );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a hash URL that will resolve to the given slide location.
|
||||
*
|
||||
|
||||
@@ -111,4 +111,10 @@ export default class Notes {
|
||||
|
||||
}
|
||||
|
||||
destroy() {
|
||||
|
||||
this.element.remove();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -238,4 +238,17 @@ export default class Plugins {
|
||||
|
||||
}
|
||||
|
||||
destroy() {
|
||||
|
||||
Object.values( this.registeredPlugins ).forEach( plugin => {
|
||||
if( typeof plugin.destroy === 'function' ) {
|
||||
plugin.destroy();
|
||||
}
|
||||
} );
|
||||
|
||||
this.registeredPlugins = {};
|
||||
this.asyncDependencies = [];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -75,6 +75,17 @@ export default class Pointer {
|
||||
|
||||
}
|
||||
|
||||
destroy() {
|
||||
|
||||
this.showCursor();
|
||||
|
||||
document.removeEventListener( 'DOMMouseScroll', this.onDocumentMouseScroll, false );
|
||||
document.removeEventListener( 'mousewheel', this.onDocumentMouseScroll, false );
|
||||
document.removeEventListener( 'mousemove', this.onDocumentCursorActive, false );
|
||||
document.removeEventListener( 'mousedown', this.onDocumentCursorActive, false );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called whenever there is mouse input at the document level
|
||||
* to determine if the cursor is active or not.
|
||||
|
||||
@@ -16,20 +16,26 @@ export default class Print {
|
||||
* Configures the presentation for printing to a static
|
||||
* PDF.
|
||||
*/
|
||||
setupPDF() {
|
||||
async setupPDF() {
|
||||
|
||||
let config = this.Reveal.getConfig();
|
||||
const config = this.Reveal.getConfig();
|
||||
const slides = queryAll( this.Reveal.getRevealElement(), SLIDES_SELECTOR )
|
||||
|
||||
let slideSize = this.Reveal.getComputedSlideSize( window.innerWidth, window.innerHeight );
|
||||
// Compute slide numbers now, before we start duplicating slides
|
||||
const doingSlideNumbers = config.slideNumber && /all|print/i.test( config.showSlideNumber );
|
||||
|
||||
const slideSize = this.Reveal.getComputedSlideSize( window.innerWidth, window.innerHeight );
|
||||
|
||||
// Dimensions of the PDF pages
|
||||
let pageWidth = Math.floor( slideSize.width * ( 1 + config.margin ) ),
|
||||
const pageWidth = Math.floor( slideSize.width * ( 1 + config.margin ) ),
|
||||
pageHeight = Math.floor( slideSize.height * ( 1 + config.margin ) );
|
||||
|
||||
// Dimensions of slides within the pages
|
||||
let slideWidth = slideSize.width,
|
||||
const slideWidth = slideSize.width,
|
||||
slideHeight = slideSize.height;
|
||||
|
||||
await new Promise( requestAnimationFrame );
|
||||
|
||||
// Let the browser know what page size we want to print
|
||||
createStyleSheet( '@page{size:'+ pageWidth +'px '+ pageHeight +'px; margin: 0px;}' );
|
||||
|
||||
@@ -40,26 +46,38 @@ export default class Print {
|
||||
document.body.style.width = pageWidth + 'px';
|
||||
document.body.style.height = pageHeight + 'px';
|
||||
|
||||
const viewportElement = document.querySelector( '.reveal-viewport' );
|
||||
let presentationBackground;
|
||||
if( viewportElement ) {
|
||||
const viewportStyles = window.getComputedStyle( viewportElement );
|
||||
if( viewportStyles && viewportStyles.background ) {
|
||||
presentationBackground = viewportStyles.background;
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure stretch elements fit on slide
|
||||
await new Promise( requestAnimationFrame );
|
||||
this.Reveal.layoutSlideContents( slideWidth, slideHeight );
|
||||
|
||||
// Compute slide numbers now, before we start duplicating slides
|
||||
let doingSlideNumbers = config.slideNumber && /all|print/i.test( config.showSlideNumber );
|
||||
queryAll( this.Reveal.getRevealElement(), SLIDES_SELECTOR ).forEach( function( slide ) {
|
||||
slide.setAttribute( 'data-slide-number', this.Reveal.slideNumber.getSlideNumber( slide ) );
|
||||
}, this );
|
||||
// Batch scrollHeight access to prevent layout thrashing
|
||||
await new Promise( requestAnimationFrame );
|
||||
|
||||
const slideScrollHeights = slides.map( slide => slide.scrollHeight );
|
||||
|
||||
const pages = [];
|
||||
const pageContainer = slides[0].parentNode;
|
||||
|
||||
// Slide and slide background layout
|
||||
queryAll( this.Reveal.getRevealElement(), SLIDES_SELECTOR ).forEach( function( slide ) {
|
||||
slides.forEach( function( slide, index ) {
|
||||
|
||||
// Vertical stacks are not centred since their section
|
||||
// children will be
|
||||
if( slide.classList.contains( 'stack' ) === false ) {
|
||||
// Center the slide inside of the page, giving the slide some margin
|
||||
let left = ( pageWidth - slideWidth ) / 2,
|
||||
top = ( pageHeight - slideHeight ) / 2;
|
||||
let left = ( pageWidth - slideWidth ) / 2;
|
||||
let top = ( pageHeight - slideHeight ) / 2;
|
||||
|
||||
let contentHeight = slide.scrollHeight;
|
||||
const contentHeight = slideScrollHeights[ index ];
|
||||
let numberOfPages = Math.max( Math.ceil( contentHeight / pageHeight ), 1 );
|
||||
|
||||
// Adhere to configured pages per slide limit
|
||||
@@ -72,10 +90,18 @@ export default class Print {
|
||||
|
||||
// Wrap the slide in a page element and hide its overflow
|
||||
// so that no page ever flows onto another
|
||||
let page = document.createElement( 'div' );
|
||||
const page = document.createElement( 'div' );
|
||||
pages.push( page );
|
||||
|
||||
page.className = 'pdf-page';
|
||||
page.style.height = ( ( pageHeight + config.pdfPageHeightOffset ) * numberOfPages ) + 'px';
|
||||
slide.parentNode.insertBefore( page, slide );
|
||||
|
||||
// Copy the presentation-wide background to each individual
|
||||
// page when printing
|
||||
if( presentationBackground ) {
|
||||
page.style.background = presentationBackground;
|
||||
}
|
||||
|
||||
page.appendChild( slide );
|
||||
|
||||
// Position the slide inside of the page
|
||||
@@ -83,6 +109,10 @@ export default class Print {
|
||||
slide.style.top = top + 'px';
|
||||
slide.style.width = slideWidth + 'px';
|
||||
|
||||
// Re-run the slide layout so that r-fit-text is applied based on
|
||||
// the printed slide size
|
||||
this.Reveal.slideContent.layout( slide )
|
||||
|
||||
if( slide.slideBackgroundElement ) {
|
||||
page.insertBefore( slide.slideBackgroundElement, slide );
|
||||
}
|
||||
@@ -91,19 +121,19 @@ export default class Print {
|
||||
if( config.showNotes ) {
|
||||
|
||||
// Are there notes for this slide?
|
||||
let notes = this.Reveal.getSlideNotes( slide );
|
||||
const notes = this.Reveal.getSlideNotes( slide );
|
||||
if( notes ) {
|
||||
|
||||
let notesSpacing = 8;
|
||||
let notesLayout = typeof config.showNotes === 'string' ? config.showNotes : 'inline';
|
||||
let notesElement = document.createElement( 'div' );
|
||||
const notesSpacing = 8;
|
||||
const notesLayout = typeof config.showNotes === 'string' ? config.showNotes : 'inline';
|
||||
const notesElement = document.createElement( 'div' );
|
||||
notesElement.classList.add( 'speaker-notes' );
|
||||
notesElement.classList.add( 'speaker-notes-pdf' );
|
||||
notesElement.setAttribute( 'data-layout', notesLayout );
|
||||
notesElement.innerHTML = notes;
|
||||
|
||||
if( notesLayout === 'separate-page' ) {
|
||||
page.parentNode.insertBefore( notesElement, page.nextSibling );
|
||||
pages.push( notesElement );
|
||||
}
|
||||
else {
|
||||
notesElement.style.left = notesSpacing + 'px';
|
||||
@@ -118,10 +148,11 @@ export default class Print {
|
||||
|
||||
// Inject slide numbers if `slideNumbers` are enabled
|
||||
if( doingSlideNumbers ) {
|
||||
let numberElement = document.createElement( 'div' );
|
||||
const slideNumber = index + 1;
|
||||
const numberElement = document.createElement( 'div' );
|
||||
numberElement.classList.add( 'slide-number' );
|
||||
numberElement.classList.add( 'slide-number-pdf' );
|
||||
numberElement.innerHTML = slide.getAttribute( 'data-slide-number' );
|
||||
numberElement.innerHTML = slideNumber;
|
||||
page.appendChild( numberElement );
|
||||
}
|
||||
|
||||
@@ -131,10 +162,9 @@ export default class Print {
|
||||
// Each fragment 'group' is an array containing one or more
|
||||
// fragments. Multiple fragments that appear at the same time
|
||||
// are part of the same group.
|
||||
let fragmentGroups = this.Reveal.fragments.sort( page.querySelectorAll( '.fragment' ), true );
|
||||
const fragmentGroups = this.Reveal.fragments.sort( page.querySelectorAll( '.fragment' ), true );
|
||||
|
||||
let previousFragmentStep;
|
||||
let previousPage;
|
||||
|
||||
fragmentGroups.forEach( function( fragments ) {
|
||||
|
||||
@@ -151,11 +181,10 @@ export default class Print {
|
||||
}, this );
|
||||
|
||||
// Create a separate page for the current fragment state
|
||||
let clonedPage = page.cloneNode( true );
|
||||
page.parentNode.insertBefore( clonedPage, ( previousPage || page ).nextSibling );
|
||||
const clonedPage = page.cloneNode( true );
|
||||
pages.push( clonedPage );
|
||||
|
||||
previousFragmentStep = fragments;
|
||||
previousPage = clonedPage;
|
||||
|
||||
}, this );
|
||||
|
||||
@@ -178,6 +207,10 @@ export default class Print {
|
||||
|
||||
}, this );
|
||||
|
||||
await new Promise( requestAnimationFrame );
|
||||
|
||||
pages.forEach( page => pageContainer.appendChild( page ) );
|
||||
|
||||
// Notify subscribers that the PDF layout is good to go
|
||||
this.Reveal.dispatchEvent({ type: 'pdf-ready' });
|
||||
|
||||
@@ -192,4 +225,4 @@ export default class Print {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,16 +88,23 @@ export default class Progress {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
let slidesTotal = this.Reveal.getHorizontalSlides().length;
|
||||
let slides = this.Reveal.getSlides();
|
||||
let slidesTotal = slides.length;
|
||||
let slideIndex = Math.floor( ( event.clientX / this.getMaxWidth() ) * slidesTotal );
|
||||
|
||||
if( this.Reveal.getConfig().rtl ) {
|
||||
slideIndex = slidesTotal - slideIndex;
|
||||
}
|
||||
|
||||
this.Reveal.slide( slideIndex );
|
||||
let targetIndices = this.Reveal.getIndices(slides[slideIndex]);
|
||||
this.Reveal.slide( targetIndices.h, targetIndices.v );
|
||||
|
||||
}
|
||||
|
||||
destroy() {
|
||||
|
||||
this.element.remove();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
import { HORIZONTAL_SLIDES_SELECTOR, VERTICAL_SLIDES_SELECTOR } from '../utils/constants.js'
|
||||
import { extend, queryAll, closest } from '../utils/util.js'
|
||||
import { extend, queryAll, closest, getMimeTypeFromFile } from '../utils/util.js'
|
||||
import { isMobile } from '../utils/device.js'
|
||||
|
||||
import fitty from 'fitty';
|
||||
@@ -102,7 +101,16 @@ export default class SlideContent {
|
||||
|
||||
// Images
|
||||
if( backgroundImage ) {
|
||||
backgroundContent.style.backgroundImage = 'url('+ encodeURI( backgroundImage ) +')';
|
||||
// base64
|
||||
if( /^data:/.test( backgroundImage.trim() ) ) {
|
||||
backgroundContent.style.backgroundImage = `url(${backgroundImage.trim()})`;
|
||||
}
|
||||
// URL(s)
|
||||
else {
|
||||
backgroundContent.style.backgroundImage = backgroundImage.split( ',' ).map( background => {
|
||||
return `url(${encodeURI(background.trim())})`;
|
||||
}).join( ',' );
|
||||
}
|
||||
}
|
||||
// Videos
|
||||
else if ( backgroundVideo && !this.Reveal.isSpeakerNotes() ) {
|
||||
@@ -128,7 +136,13 @@ export default class SlideContent {
|
||||
|
||||
// Support comma separated lists of video sources
|
||||
backgroundVideo.split( ',' ).forEach( source => {
|
||||
video.innerHTML += '<source src="'+ source +'">';
|
||||
let type = getMimeTypeFromFile( source );
|
||||
if( type ) {
|
||||
video.innerHTML += `<source src="${source}" type="${type}">`;
|
||||
}
|
||||
else {
|
||||
video.innerHTML += `<source src="${source}">`;
|
||||
}
|
||||
} );
|
||||
|
||||
backgroundContent.appendChild( video );
|
||||
@@ -167,11 +181,20 @@ export default class SlideContent {
|
||||
|
||||
}
|
||||
|
||||
this.layout( slide );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies JS-dependent layout helpers for the given slide,
|
||||
* if there are any.
|
||||
*/
|
||||
layout( slide ) {
|
||||
|
||||
// Autosize text with the r-fit-text class based on the
|
||||
// size of its container. This needs to happen after the
|
||||
// slide is visible in order to measure the text.
|
||||
Array.from( slide.querySelectorAll( '.r-fit-text:not([data-fitted])' ) ).forEach( element => {
|
||||
element.dataset.fitted = '';
|
||||
Array.from( slide.querySelectorAll( '.r-fit-text' ) ).forEach( element => {
|
||||
fitty( element, {
|
||||
minSize: 24,
|
||||
maxSize: this.Reveal.getConfig().height * 0.8,
|
||||
@@ -453,4 +476,4 @@ export default class SlideContent {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,4 +123,10 @@ export default class SlideNumber {
|
||||
|
||||
}
|
||||
|
||||
destroy() {
|
||||
|
||||
this.element.remove();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { isAndroid } from '../utils/device.js'
|
||||
import { matches } from '../utils/util.js'
|
||||
|
||||
const SWIPE_THRESHOLD = 40;
|
||||
|
||||
@@ -82,6 +83,9 @@ export default class Touch {
|
||||
*/
|
||||
isSwipePrevented( target ) {
|
||||
|
||||
// Prevent accidental swipes when scrubbing timelines
|
||||
if( matches( target, 'video, audio' ) ) return true;
|
||||
|
||||
while( target && typeof target.hasAttribute === 'function' ) {
|
||||
if( target.hasAttribute( 'data-prevent-swipe' ) ) return true;
|
||||
target = target.parentNode;
|
||||
|
||||
@@ -26,14 +26,14 @@ import {
|
||||
} from './utils/constants.js'
|
||||
|
||||
// The reveal.js version
|
||||
export const VERSION = '4.1.0';
|
||||
export const VERSION = '4.3.1';
|
||||
|
||||
/**
|
||||
* reveal.js
|
||||
* https://revealjs.com
|
||||
* MIT licensed
|
||||
*
|
||||
* Copyright (C) 2020 Hakim El Hattab, https://hakim.se
|
||||
* Copyright (C) 2011-2022 Hakim El Hattab, https://hakim.se
|
||||
*/
|
||||
export default function( revealElement, options ) {
|
||||
|
||||
@@ -121,10 +121,14 @@ export default function( revealElement, options ) {
|
||||
*/
|
||||
function initialize( initOptions ) {
|
||||
|
||||
if( !revealElement ) throw 'Unable to find presentation root (<div class="reveal">).';
|
||||
|
||||
// Cache references to key DOM elements
|
||||
dom.wrapper = revealElement;
|
||||
dom.slides = revealElement.querySelector( '.slides' );
|
||||
|
||||
if( !dom.slides ) throw 'Unable to find slides container (<div class="slides">).';
|
||||
|
||||
// Compose our config object in order of increasing precedence:
|
||||
// 1. Default reveal.js options
|
||||
// 2. Options provided via Reveal.configure() prior to
|
||||
@@ -186,6 +190,9 @@ export default function( revealElement, options ) {
|
||||
// Prevent the slides from being scrolled out of view
|
||||
setupScrollPrevention();
|
||||
|
||||
// Adds bindings for fullscreen mode
|
||||
setupFullscreen();
|
||||
|
||||
// Resets all vertical slides so that only the first is visible
|
||||
resetVerticalSlides();
|
||||
|
||||
@@ -372,6 +379,19 @@ export default function( revealElement, options ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* After entering fullscreen we need to force a layout to
|
||||
* get our presentations to scale correctly. This behavior
|
||||
* is inconsistent across browsers but a force layout seems
|
||||
* to normalize it.
|
||||
*/
|
||||
function setupFullscreen() {
|
||||
|
||||
document.addEventListener( 'fullscreenchange', onFullscreenChange );
|
||||
document.addEventListener( 'webkitfullscreenchange', onFullscreenChange );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a listener to postMessage events, this makes it
|
||||
* possible to call all reveal.js API methods from another
|
||||
@@ -385,32 +405,7 @@ export default function( revealElement, options ) {
|
||||
function setupPostMessage() {
|
||||
|
||||
if( config.postMessage ) {
|
||||
window.addEventListener( 'message', event => {
|
||||
let data = event.data;
|
||||
|
||||
// Make sure we're dealing with JSON
|
||||
if( typeof data === 'string' && data.charAt( 0 ) === '{' && data.charAt( data.length - 1 ) === '}' ) {
|
||||
data = JSON.parse( data );
|
||||
|
||||
// Check if the requested method can be found
|
||||
if( data.method && typeof Reveal[data.method] === 'function' ) {
|
||||
|
||||
if( POST_MESSAGE_METHOD_BLACKLIST.test( data.method ) === false ) {
|
||||
|
||||
const result = Reveal[data.method].apply( Reveal, data.args );
|
||||
|
||||
// Dispatch a postMessage event with the returned value from
|
||||
// our method invocation for getter functions
|
||||
dispatchPostMessage( 'callback', { method: data.method, result: result } );
|
||||
|
||||
}
|
||||
else {
|
||||
console.warn( 'reveal.js: "'+ data.method +'" is is blacklisted from the postMessage API' );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}, false );
|
||||
window.addEventListener( 'message', onPostMessage, false );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -525,6 +520,7 @@ export default function( revealElement, options ) {
|
||||
controls.bind();
|
||||
focus.bind();
|
||||
|
||||
dom.slides.addEventListener( 'click', onSlidesClicked, false );
|
||||
dom.slides.addEventListener( 'transitionend', onTransitionEnd, false );
|
||||
dom.pauseOverlay.addEventListener( 'click', resume, false );
|
||||
|
||||
@@ -550,11 +546,71 @@ export default function( revealElement, options ) {
|
||||
|
||||
window.removeEventListener( 'resize', onWindowResize, false );
|
||||
|
||||
dom.slides.removeEventListener( 'click', onSlidesClicked, false );
|
||||
dom.slides.removeEventListener( 'transitionend', onTransitionEnd, false );
|
||||
dom.pauseOverlay.removeEventListener( 'click', resume, false );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninitializes reveal.js by undoing changes made to the
|
||||
* DOM and removing all event listeners.
|
||||
*/
|
||||
function destroy() {
|
||||
|
||||
removeEventListeners();
|
||||
cancelAutoSlide();
|
||||
disablePreviewLinks();
|
||||
|
||||
// Destroy controllers
|
||||
notes.destroy();
|
||||
focus.destroy();
|
||||
plugins.destroy();
|
||||
pointer.destroy();
|
||||
controls.destroy();
|
||||
progress.destroy();
|
||||
backgrounds.destroy();
|
||||
slideNumber.destroy();
|
||||
|
||||
// Remove event listeners
|
||||
document.removeEventListener( 'fullscreenchange', onFullscreenChange );
|
||||
document.removeEventListener( 'webkitfullscreenchange', onFullscreenChange );
|
||||
document.removeEventListener( 'visibilitychange', onPageVisibilityChange, false );
|
||||
window.removeEventListener( 'message', onPostMessage, false );
|
||||
window.removeEventListener( 'load', layout, false );
|
||||
|
||||
// Undo DOM changes
|
||||
if( dom.pauseOverlay ) dom.pauseOverlay.remove();
|
||||
if( dom.statusElement ) dom.statusElement.remove();
|
||||
|
||||
document.documentElement.classList.remove( 'reveal-full-page' );
|
||||
|
||||
dom.wrapper.classList.remove( 'ready', 'center', 'has-horizontal-slides', 'has-vertical-slides' );
|
||||
dom.wrapper.removeAttribute( 'data-transition-speed' );
|
||||
dom.wrapper.removeAttribute( 'data-background-transition' );
|
||||
|
||||
dom.viewport.classList.remove( 'reveal-viewport' );
|
||||
dom.viewport.style.removeProperty( '--slide-width' );
|
||||
dom.viewport.style.removeProperty( '--slide-height' );
|
||||
|
||||
dom.slides.style.removeProperty( 'width' );
|
||||
dom.slides.style.removeProperty( 'height' );
|
||||
dom.slides.style.removeProperty( 'zoom' );
|
||||
dom.slides.style.removeProperty( 'left' );
|
||||
dom.slides.style.removeProperty( 'top' );
|
||||
dom.slides.style.removeProperty( 'bottom' );
|
||||
dom.slides.style.removeProperty( 'right' );
|
||||
dom.slides.style.removeProperty( 'transform' );
|
||||
|
||||
Array.from( dom.wrapper.querySelectorAll( SLIDES_SELECTOR ) ).forEach( slide => {
|
||||
slide.style.removeProperty( 'display' );
|
||||
slide.style.removeProperty( 'top' );
|
||||
slide.removeAttribute( 'hidden' );
|
||||
slide.removeAttribute( 'aria-hidden' );
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a listener to one of our custom reveal.js events,
|
||||
* like slidechanged.
|
||||
@@ -614,6 +670,8 @@ export default function( revealElement, options ) {
|
||||
dispatchPostMessage( type );
|
||||
}
|
||||
|
||||
return event;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1188,9 +1246,22 @@ export default function( revealElement, options ) {
|
||||
* @param {number} [v=indexv] Vertical index of the target slide
|
||||
* @param {number} [f] Index of a fragment within the
|
||||
* target slide to activate
|
||||
* @param {number} [o] Origin for use in multimaster environments
|
||||
* @param {number} [origin] Origin for use in multimaster environments
|
||||
*/
|
||||
function slide( h, v, f, o ) {
|
||||
function slide( h, v, f, origin ) {
|
||||
|
||||
// Dispatch an event before hte slide
|
||||
const slidechange = dispatchEvent({
|
||||
type: 'beforeslidechange',
|
||||
data: {
|
||||
indexh: h === undefined ? indexh : h,
|
||||
indexv: v === undefined ? indexv : v,
|
||||
origin
|
||||
}
|
||||
});
|
||||
|
||||
// Abort if this slide change was prevented by an event listener
|
||||
if( slidechange.defaultPrevented ) return;
|
||||
|
||||
// Remember where we were at before
|
||||
previousSlide = currentSlide;
|
||||
@@ -1251,7 +1322,10 @@ export default function( revealElement, options ) {
|
||||
// Note 20-03-2020:
|
||||
// This needs to happen before we update slide visibility,
|
||||
// otherwise transitions will still run in Safari.
|
||||
if( previousSlide.hasAttribute( 'data-auto-animate' ) && currentSlide.hasAttribute( 'data-auto-animate' ) ) {
|
||||
if( previousSlide.hasAttribute( 'data-auto-animate' ) && currentSlide.hasAttribute( 'data-auto-animate' )
|
||||
&& previousSlide.getAttribute( 'data-auto-animate-id' ) === currentSlide.getAttribute( 'data-auto-animate-id' )
|
||||
&& !( ( indexh > indexhBefore || indexv > indexvBefore ) ? currentSlide : previousSlide ).hasAttribute( 'data-auto-animate-restart' ) ) {
|
||||
|
||||
autoAnimateTransition = true;
|
||||
dom.slides.classList.add( 'disable-slide-transitions' );
|
||||
}
|
||||
@@ -1323,7 +1397,7 @@ export default function( revealElement, options ) {
|
||||
indexv,
|
||||
previousSlide,
|
||||
currentSlide,
|
||||
origin: o
|
||||
origin
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1335,7 +1409,11 @@ export default function( revealElement, options ) {
|
||||
}
|
||||
|
||||
// Announce the current slide contents to screen readers
|
||||
announceStatus( getStatusText( currentSlide ) );
|
||||
// Use animation frame to prevent getComputedStyle in getStatusText
|
||||
// from triggering layout mid-frame
|
||||
requestAnimationFrame( () => {
|
||||
announceStatus( getStatusText( currentSlide ) );
|
||||
});
|
||||
|
||||
progress.update();
|
||||
controls.update();
|
||||
@@ -2186,55 +2264,55 @@ export default function( revealElement, options ) {
|
||||
|
||||
}
|
||||
|
||||
function navigateLeft() {
|
||||
function navigateLeft({skipFragments=false}={}) {
|
||||
|
||||
navigationHistory.hasNavigatedHorizontally = true;
|
||||
|
||||
// Reverse for RTL
|
||||
if( config.rtl ) {
|
||||
if( ( overview.isActive() || fragments.next() === false ) && availableRoutes().left ) {
|
||||
if( ( overview.isActive() || skipFragments || fragments.next() === false ) && availableRoutes().left ) {
|
||||
slide( indexh + 1, config.navigationMode === 'grid' ? indexv : undefined );
|
||||
}
|
||||
}
|
||||
// Normal navigation
|
||||
else if( ( overview.isActive() || fragments.prev() === false ) && availableRoutes().left ) {
|
||||
else if( ( overview.isActive() || skipFragments || fragments.prev() === false ) && availableRoutes().left ) {
|
||||
slide( indexh - 1, config.navigationMode === 'grid' ? indexv : undefined );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function navigateRight() {
|
||||
function navigateRight({skipFragments=false}={}) {
|
||||
|
||||
navigationHistory.hasNavigatedHorizontally = true;
|
||||
|
||||
// Reverse for RTL
|
||||
if( config.rtl ) {
|
||||
if( ( overview.isActive() || fragments.prev() === false ) && availableRoutes().right ) {
|
||||
if( ( overview.isActive() || skipFragments || fragments.prev() === false ) && availableRoutes().right ) {
|
||||
slide( indexh - 1, config.navigationMode === 'grid' ? indexv : undefined );
|
||||
}
|
||||
}
|
||||
// Normal navigation
|
||||
else if( ( overview.isActive() || fragments.next() === false ) && availableRoutes().right ) {
|
||||
else if( ( overview.isActive() || skipFragments || fragments.next() === false ) && availableRoutes().right ) {
|
||||
slide( indexh + 1, config.navigationMode === 'grid' ? indexv : undefined );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function navigateUp() {
|
||||
function navigateUp({skipFragments=false}={}) {
|
||||
|
||||
// Prioritize hiding fragments
|
||||
if( ( overview.isActive() || fragments.prev() === false ) && availableRoutes().up ) {
|
||||
if( ( overview.isActive() || skipFragments || fragments.prev() === false ) && availableRoutes().up ) {
|
||||
slide( indexh, indexv - 1 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function navigateDown() {
|
||||
function navigateDown({skipFragments=false}={}) {
|
||||
|
||||
navigationHistory.hasNavigatedVertically = true;
|
||||
|
||||
// Prioritize revealing fragments
|
||||
if( ( overview.isActive() || fragments.next() === false ) && availableRoutes().down ) {
|
||||
if( ( overview.isActive() || skipFragments || fragments.next() === false ) && availableRoutes().down ) {
|
||||
slide( indexh, indexv + 1 );
|
||||
}
|
||||
|
||||
@@ -2246,12 +2324,12 @@ export default function( revealElement, options ) {
|
||||
* 2) Previous vertical slide
|
||||
* 3) Previous horizontal slide
|
||||
*/
|
||||
function navigatePrev() {
|
||||
function navigatePrev({skipFragments=false}={}) {
|
||||
|
||||
// Prioritize revealing fragments
|
||||
if( fragments.prev() === false ) {
|
||||
if( skipFragments || fragments.prev() === false ) {
|
||||
if( availableRoutes().up ) {
|
||||
navigateUp();
|
||||
navigateUp({skipFragments});
|
||||
}
|
||||
else {
|
||||
// Fetch the previous horizontal slide, if there is one
|
||||
@@ -2264,11 +2342,16 @@ export default function( revealElement, options ) {
|
||||
previousSlide = Util.queryAll( dom.wrapper, HORIZONTAL_SLIDES_SELECTOR + '.past' ).pop();
|
||||
}
|
||||
|
||||
if( previousSlide ) {
|
||||
// When going backwards and arriving on a stack we start
|
||||
// at the bottom of the stack
|
||||
if( previousSlide && previousSlide.classList.contains( 'stack' ) ) {
|
||||
let v = ( previousSlide.querySelectorAll( 'section' ).length - 1 ) || undefined;
|
||||
let h = indexh - 1;
|
||||
slide( h, v );
|
||||
}
|
||||
else {
|
||||
navigateLeft({skipFragments});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2277,31 +2360,31 @@ export default function( revealElement, options ) {
|
||||
/**
|
||||
* The reverse of #navigatePrev().
|
||||
*/
|
||||
function navigateNext() {
|
||||
function navigateNext({skipFragments=false}={}) {
|
||||
|
||||
navigationHistory.hasNavigatedHorizontally = true;
|
||||
navigationHistory.hasNavigatedVertically = true;
|
||||
|
||||
// Prioritize revealing fragments
|
||||
if( fragments.next() === false ) {
|
||||
if( skipFragments || fragments.next() === false ) {
|
||||
|
||||
let routes = availableRoutes();
|
||||
|
||||
// When looping is enabled `routes.down` is always available
|
||||
// so we need a separate check for when we've reached the
|
||||
// end of a stack and should move horizontally
|
||||
if( routes.down && routes.right && config.loop && isLastVerticalSlide( currentSlide ) ) {
|
||||
if( routes.down && routes.right && config.loop && isLastVerticalSlide() ) {
|
||||
routes.down = false;
|
||||
}
|
||||
|
||||
if( routes.down ) {
|
||||
navigateDown();
|
||||
navigateDown({skipFragments});
|
||||
}
|
||||
else if( config.rtl ) {
|
||||
navigateLeft();
|
||||
navigateLeft({skipFragments});
|
||||
}
|
||||
else {
|
||||
navigateRight();
|
||||
navigateRight({skipFragments});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2326,6 +2409,38 @@ export default function( revealElement, options ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Listener for post message events posted to this window.
|
||||
*/
|
||||
function onPostMessage( event ) {
|
||||
|
||||
let data = event.data;
|
||||
|
||||
// Make sure we're dealing with JSON
|
||||
if( typeof data === 'string' && data.charAt( 0 ) === '{' && data.charAt( data.length - 1 ) === '}' ) {
|
||||
data = JSON.parse( data );
|
||||
|
||||
// Check if the requested method can be found
|
||||
if( data.method && typeof Reveal[data.method] === 'function' ) {
|
||||
|
||||
if( POST_MESSAGE_METHOD_BLACKLIST.test( data.method ) === false ) {
|
||||
|
||||
const result = Reveal[data.method].apply( Reveal, data.args );
|
||||
|
||||
// Dispatch a postMessage event with the returned value from
|
||||
// our method invocation for getter functions
|
||||
dispatchPostMessage( 'callback', { method: data.method, result: result } );
|
||||
|
||||
}
|
||||
else {
|
||||
console.warn( 'reveal.js: "'+ data.method +'" is is blacklisted from the postMessage API' );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Event listener for transition end on the current slide.
|
||||
*
|
||||
@@ -2343,6 +2458,33 @@ export default function( revealElement, options ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A global listener for all click events inside of the
|
||||
* .slides container.
|
||||
*
|
||||
* @param {object} [event]
|
||||
*/
|
||||
function onSlidesClicked( event ) {
|
||||
|
||||
const anchor = Util.closest( event.target, 'a[href^="#"]' );
|
||||
|
||||
// If a hash link is clicked, we find the target slide
|
||||
// and navigate to it. We previously relied on 'hashchange'
|
||||
// for links like these but that prevented media with
|
||||
// audio tracks from playing in mobile browsers since it
|
||||
// wasn't considered a direct interaction with the document.
|
||||
if( anchor ) {
|
||||
const hash = anchor.getAttribute( 'href' );
|
||||
const indices = location.getIndicesFromHash( hash );
|
||||
|
||||
if( indices ) {
|
||||
Reveal.slide( indices.h, indices.v, indices.f );
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for the window level 'resize' event.
|
||||
*
|
||||
@@ -2373,6 +2515,26 @@ export default function( revealElement, options ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for the document level 'fullscreenchange' event.
|
||||
*
|
||||
* @param {object} [event]
|
||||
*/
|
||||
function onFullscreenChange( event ) {
|
||||
|
||||
let element = document.fullscreenElement || document.webkitFullscreenElement;
|
||||
if( element === dom.wrapper ) {
|
||||
event.stopImmediatePropagation();
|
||||
|
||||
// Timeout to avoid layout shift in Safari
|
||||
setTimeout( () => {
|
||||
Reveal.layout();
|
||||
Reveal.focus.focus(); // focus.focus :'(
|
||||
}, 1 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles clicks on links that are set to preview in the
|
||||
* iframe overlay.
|
||||
@@ -2425,6 +2587,7 @@ export default function( revealElement, options ) {
|
||||
|
||||
initialize,
|
||||
configure,
|
||||
destroy,
|
||||
|
||||
sync,
|
||||
syncSlide,
|
||||
@@ -2500,6 +2663,10 @@ export default function( revealElement, options ) {
|
||||
loadSlide: slideContent.load.bind( slideContent ),
|
||||
unloadSlide: slideContent.unload.bind( slideContent ),
|
||||
|
||||
// Preview management
|
||||
showPreview,
|
||||
hidePreview: closeOverlay,
|
||||
|
||||
// Adds or removes all internal event listeners
|
||||
addEventListeners,
|
||||
removeEventListeners,
|
||||
@@ -2577,6 +2744,9 @@ export default function( revealElement, options ) {
|
||||
// Helper method, retrieves query string as a key:value map
|
||||
getQueryHash: Util.getQueryHash,
|
||||
|
||||
// Returns the path to the current slide as represented in the URL
|
||||
getSlidePath: location.getHash.bind( location ),
|
||||
|
||||
// Returns reveal.js DOM elements
|
||||
getRevealElement: () => revealElement,
|
||||
getSlidesElement: () => dom.slides,
|
||||
|
||||
@@ -29,9 +29,9 @@ export const colorToRgb = ( color ) => {
|
||||
if( hex6 && hex6[1] ) {
|
||||
hex6 = hex6[1];
|
||||
return {
|
||||
r: parseInt( hex6.substr( 0, 2 ), 16 ),
|
||||
g: parseInt( hex6.substr( 2, 2 ), 16 ),
|
||||
b: parseInt( hex6.substr( 4, 2 ), 16 )
|
||||
r: parseInt( hex6.slice( 0, 2 ), 16 ),
|
||||
g: parseInt( hex6.slice( 2, 4 ), 16 ),
|
||||
b: parseInt( hex6.slice( 4, 6 ), 16 )
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -279,4 +279,19 @@ export const getRemainingHeight = ( element, height = 0 ) => {
|
||||
|
||||
return height;
|
||||
|
||||
}
|
||||
|
||||
const fileExtensionToMimeMap = {
|
||||
'mp4': 'video/mp4',
|
||||
'm4a': 'video/mp4',
|
||||
'ogv': 'video/ogg',
|
||||
'mpeg': 'video/mpeg',
|
||||
'webm': 'video/webm'
|
||||
}
|
||||
|
||||
/**
|
||||
* Guess the MIME type for common file formats.
|
||||
*/
|
||||
export const getMimeTypeFromFile = ( filename='' ) => {
|
||||
return fileExtensionToMimeMap[filename.split('.').pop()]
|
||||
}
|
||||
Reference in New Issue
Block a user