merge upstream

This commit is contained in:
Kathleen Fitzpatrick
2024-10-13 15:31:20 -04:00
77 changed files with 2281 additions and 3223 deletions

View File

@@ -31,10 +31,13 @@ export default class AutoAnimate {
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' )
// Ensure that;
// 1. Both slides exist.
// 2. Both slides are auto-animate targets with the same
// data-auto-animate-id value (including null if absent on both).
// 3. data-auto-animate-restart isn't set on the physically latter
// slide (independent of slide direction).
if( fromSlide && toSlide && 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' ) ) {

View File

@@ -268,14 +268,15 @@ export default class Backgrounds {
*/
update( includeAll = false ) {
let config = this.Reveal.getConfig();
let currentSlide = this.Reveal.getCurrentSlide();
let indices = this.Reveal.getIndices();
let currentBackground = null;
// Reverse past/future classes when in RTL mode
let horizontalPast = this.Reveal.getConfig().rtl ? 'future' : 'past',
horizontalFuture = this.Reveal.getConfig().rtl ? 'past' : 'future';
let horizontalPast = config.rtl ? 'future' : 'past',
horizontalFuture = config.rtl ? 'past' : 'future';
// Update the classes of all backgrounds to match the
// states of their slides (past/present/future)
@@ -301,10 +302,12 @@ export default class Backgrounds {
backgroundv.classList.remove( 'past', 'present', 'future' );
if( v < indices.v ) {
const indexv = typeof indices.v === 'number' ? indices.v : 0;
if( v < indexv ) {
backgroundv.classList.add( 'past' );
}
else if ( v > indices.v ) {
else if ( v > indexv ) {
backgroundv.classList.add( 'future' );
}
else {
@@ -319,6 +322,42 @@ export default class Backgrounds {
} );
// The previous background may refer to a DOM element that has
// been removed after a presentation is synced & bgs are recreated
if( this.previousBackground && !this.previousBackground.closest( 'body' ) ) {
this.previousBackground = null;
}
if( currentBackground && this.previousBackground ) {
// Don't transition between identical backgrounds. This
// prevents unwanted flicker.
let previousBackgroundHash = this.previousBackground.getAttribute( 'data-background-hash' );
let currentBackgroundHash = currentBackground.getAttribute( 'data-background-hash' );
if( currentBackgroundHash && currentBackgroundHash === previousBackgroundHash && currentBackground !== this.previousBackground ) {
this.element.classList.add( 'no-transition' );
// If multiple slides have the same background video, carry
// the <video> element forward so that it plays continuously
// across multiple slides
const currentVideo = currentBackground.querySelector( 'video' );
const previousVideo = this.previousBackground.querySelector( 'video' );
if( currentVideo && previousVideo ) {
const currentVideoParent = currentVideo.parentNode;
const previousVideoParent = previousVideo.parentNode;
// Swap the two videos
previousVideoParent.appendChild( currentVideo );
currentVideoParent.appendChild( previousVideo );
}
}
}
// Stop content inside of previous backgrounds
if( this.previousBackground ) {
@@ -345,14 +384,6 @@ export default class Backgrounds {
}
// Don't transition between identical backgrounds. This
// prevents unwanted flicker.
let previousBackgroundHash = this.previousBackground ? this.previousBackground.getAttribute( 'data-background-hash' ) : null;
let currentBackgroundHash = currentBackground.getAttribute( 'data-background-hash' );
if( currentBackgroundHash && currentBackgroundHash === previousBackgroundHash && currentBackground !== this.previousBackground ) {
this.element.classList.add( 'no-transition' );
}
this.previousBackground = currentBackground;
}
@@ -366,7 +397,7 @@ export default class Backgrounds {
// Allow the first background to apply without transition
setTimeout( () => {
this.element.classList.remove( 'no-transition' );
}, 1 );
}, 10 );
}

View File

@@ -1,4 +1,4 @@
import { queryAll } from '../utils/util.js'
import { queryAll, enterFullscreen } from '../utils/util.js'
import { isAndroid } from '../utils/device.js'
/**
@@ -12,6 +12,7 @@ import { isAndroid } from '../utils/device.js'
* - .navigate-left
* - .navigate-next
* - .navigate-prev
* - .enter-fullscreen
*/
export default class Controls {
@@ -25,6 +26,7 @@ export default class Controls {
this.onNavigateDownClicked = this.onNavigateDownClicked.bind( this );
this.onNavigatePrevClicked = this.onNavigatePrevClicked.bind( this );
this.onNavigateNextClicked = this.onNavigateNextClicked.bind( this );
this.onEnterFullscreen = this.onEnterFullscreen.bind( this );
}
@@ -50,6 +52,7 @@ export default class Controls {
this.controlsDown = queryAll( revealElement, '.navigate-down' );
this.controlsPrev = queryAll( revealElement, '.navigate-prev' );
this.controlsNext = queryAll( revealElement, '.navigate-next' );
this.controlsFullscreen = queryAll( revealElement, '.enter-fullscreen' );
// The left, right and down arrows in the standard reveal.js controls
this.controlsRightArrow = this.element.querySelector( '.navigate-right' );
@@ -89,6 +92,7 @@ export default class Controls {
this.controlsDown.forEach( el => el.addEventListener( eventName, this.onNavigateDownClicked, false ) );
this.controlsPrev.forEach( el => el.addEventListener( eventName, this.onNavigatePrevClicked, false ) );
this.controlsNext.forEach( el => el.addEventListener( eventName, this.onNavigateNextClicked, false ) );
this.controlsFullscreen.forEach( el => el.addEventListener( eventName, this.onEnterFullscreen, false ) );
} );
}
@@ -102,6 +106,7 @@ export default class Controls {
this.controlsDown.forEach( el => el.removeEventListener( eventName, this.onNavigateDownClicked, false ) );
this.controlsPrev.forEach( el => el.removeEventListener( eventName, this.onNavigatePrevClicked, false ) );
this.controlsNext.forEach( el => el.removeEventListener( eventName, this.onNavigateNextClicked, false ) );
this.controlsFullscreen.forEach( el => el.removeEventListener( eventName, this.onEnterFullscreen, false ) );
} );
}
@@ -262,5 +267,13 @@ export default class Controls {
}
onEnterFullscreen( event ) {
const config = this.Reveal.getConfig();
const viewport = this.Reveal.getViewportElement();
enterFullscreen( config.embedded ? viewport : viewport.parentElement );
}
}

View File

@@ -257,6 +257,26 @@ export default class Fragments {
}
if( changedFragments.hidden.length ) {
this.Reveal.dispatchEvent({
type: 'fragmenthidden',
data: {
fragment: changedFragments.hidden[0],
fragments: changedFragments.hidden
}
});
}
if( changedFragments.shown.length ) {
this.Reveal.dispatchEvent({
type: 'fragmentshown',
data: {
fragment: changedFragments.shown[0],
fragments: changedFragments.shown
}
});
}
return changedFragments;
}
@@ -311,26 +331,6 @@ export default class Fragments {
let changedFragments = this.update( index, fragments );
if( changedFragments.hidden.length ) {
this.Reveal.dispatchEvent({
type: 'fragmenthidden',
data: {
fragment: changedFragments.hidden[0],
fragments: changedFragments.hidden
}
});
}
if( changedFragments.shown.length ) {
this.Reveal.dispatchEvent({
type: 'fragmentshown',
data: {
fragment: changedFragments.shown[0],
fragments: changedFragments.shown
}
});
}
this.Reveal.controls.update();
this.Reveal.progress.update();

View File

@@ -1,3 +1,8 @@
import {
SLIDE_NUMBER_FORMAT_CURRENT,
SLIDE_NUMBER_FORMAT_CURRENT_SLASH_TOTAL
} from "../utils/constants";
/**
* Makes it possible to jump to a slide by entering its
* slide number or id.
@@ -66,11 +71,33 @@ export default class JumpToSlide {
clearTimeout( this.jumpTimeout );
delete this.jumpTimeout;
const query = this.jumpInput.value.trim( '' );
let indices = this.Reveal.location.getIndicesFromHash( query, { oneBasedIndex: true } );
let query = this.jumpInput.value.trim( '' );
let indices;
// If no valid index was found and the input query is a
// string, fall back on a simple search
// When slide numbers are formatted to be a single linear mumber
// (instead of showing a separate horizontal/vertical index) we
// use the same format for slide jumps
if( /^\d+$/.test( query ) ) {
const slideNumberFormat = this.Reveal.getConfig().slideNumber;
if( slideNumberFormat === SLIDE_NUMBER_FORMAT_CURRENT || slideNumberFormat === SLIDE_NUMBER_FORMAT_CURRENT_SLASH_TOTAL ) {
const slide = this.Reveal.getSlides()[ parseInt( query, 10 ) - 1 ];
if( slide ) {
indices = this.Reveal.getIndices( slide );
}
}
}
if( !indices ) {
// If the query uses "horizontal.vertical" format, convert to
// "horizontal/vertical" so that our URL parser can understand
if( /^\d+\.\d+$/.test( query ) ) {
query = query.replace( '.', '/' );
}
indices = this.Reveal.location.getIndicesFromHash( query, { oneBasedIndex: true } );
}
// Still no valid index? Fall back on a text search
if( !indices && /\S+/i.test( query ) && query.length > 1 ) {
indices = this.search( query );
}

View File

@@ -167,7 +167,7 @@ export default class Keyboard {
let activeElementIsNotes = document.activeElement && document.activeElement.className && /speaker-notes/i.test( document.activeElement.className);
// Whitelist certain modifiers for slide navigation shortcuts
let keyCodeUsesModifier = [32, 37, 38, 39, 40, 78, 80, 191].indexOf( event.keyCode ) !== -1;
let keyCodeUsesModifier = [32, 37, 38, 39, 40, 63, 78, 80, 191].indexOf( event.keyCode ) !== -1;
// Prevent all other events when a modifier is pressed
let unusedModifier = !( keyCodeUsesModifier && event.shiftKey || event.altKey ) &&
@@ -178,7 +178,7 @@ export default class Keyboard {
if( activeElementIsCE || activeElementIsInput || activeElementIsNotes || unusedModifier ) return;
// While paused only allow resume keyboard events; 'b', 'v', '.'
let resumeKeyCodes = [66,86,190,191];
let resumeKeyCodes = [66,86,190,191,112];
let key;
// Custom key bindings for togglePause should be able to resume
@@ -271,7 +271,12 @@ export default class Keyboard {
this.Reveal.slide( 0 );
}
else if( !this.Reveal.overview.isActive() && useLinearMode ) {
this.Reveal.prev({skipFragments: event.altKey});
if( config.rtl ) {
this.Reveal.next({skipFragments: event.altKey});
}
else {
this.Reveal.prev({skipFragments: event.altKey});
}
}
else {
this.Reveal.left({skipFragments: event.altKey});
@@ -283,7 +288,12 @@ export default class Keyboard {
this.Reveal.slide( this.Reveal.getHorizontalSlides().length - 1 );
}
else if( !this.Reveal.overview.isActive() && useLinearMode ) {
this.Reveal.next({skipFragments: event.altKey});
if( config.rtl ) {
this.Reveal.prev({skipFragments: event.altKey});
}
else {
this.Reveal.next({skipFragments: event.altKey});
}
}
else {
this.Reveal.right({skipFragments: event.altKey});
@@ -354,7 +364,11 @@ export default class Keyboard {
}
}
// ?
else if( keyCode === 191 && event.shiftKey ) {
else if( ( keyCode === 63 || keyCode === 191 ) && event.shiftKey ) {
this.Reveal.toggleHelp();
}
// F1
else if( keyCode === 112 ) {
this.Reveal.toggleHelp();
}
else {
@@ -383,4 +397,4 @@ export default class Keyboard {
}
}
}

View File

@@ -223,6 +223,8 @@ export default class PrintView {
// Notify subscribers that the PDF layout is good to go
this.Reveal.dispatchEvent({ type: 'pdf-ready' });
viewportElement.classList.remove( 'loading-scroll-mode' );
}
/**

View File

@@ -1,4 +1,4 @@
import { HORIZONTAL_SLIDES_SELECTOR } from '../utils/constants.js'
import { HORIZONTAL_SLIDES_SELECTOR, HORIZONTAL_BACKGROUNDS_SELECTOR } from '../utils/constants.js'
import { queryAll } from '../utils/util.js'
const HIDE_SCROLLBAR_TIMEOUT = 500;
@@ -40,6 +40,7 @@ export default class ScrollView {
this.slideHTMLBeforeActivation = this.Reveal.getSlidesElement().innerHTML;
const horizontalSlides = queryAll( this.Reveal.getRevealElement(), HORIZONTAL_SLIDES_SELECTOR );
const horizontalBackgrounds = queryAll( this.Reveal.getRevealElement(), HORIZONTAL_BACKGROUNDS_SELECTOR );
this.viewportElement.classList.add( 'loading-scroll-mode', 'reveal-scroll' );
@@ -57,7 +58,7 @@ export default class ScrollView {
// Creates a new page element and appends the given slide/bg
// to it.
const createPageElement = ( slide, h, v ) => {
const createPageElement = ( slide, h, v, isVertical ) => {
let contentContainer;
@@ -76,8 +77,20 @@ export default class ScrollView {
page.className = 'scroll-page';
pageElements.push( page );
// Copy the presentation-wide background to each page
if( presentationBackground ) {
// This transfers over the background of the vertical stack containing
// the slide if it exists. Otherwise, it uses the presentation-wide
// background.
if( isVertical && horizontalBackgrounds.length > h ) {
const slideBackground = horizontalBackgrounds[h];
const pageBackground = window.getComputedStyle( slideBackground );
if( pageBackground && pageBackground.background ) {
page.style.background = pageBackground.background;
}
else if( presentationBackground ) {
page.style.background = presentationBackground;
}
} else if( presentationBackground ) {
page.style.background = presentationBackground;
}
@@ -110,7 +123,7 @@ export default class ScrollView {
if( this.Reveal.isVerticalStack( horizontalSlide ) ) {
horizontalSlide.querySelectorAll( 'section' ).forEach( ( verticalSlide, v ) => {
createPageElement( verticalSlide, h, v );
createPageElement( verticalSlide, h, v, true );
});
}
else {
@@ -277,7 +290,7 @@ export default class ScrollView {
const pageHeight = useCompactLayout ? compactHeight : viewportHeight;
// The height that needs to be scrolled between scroll triggers
const scrollTriggerHeight = useCompactLayout ? compactHeight : viewportHeight;
this.scrollTriggerHeight = useCompactLayout ? compactHeight : viewportHeight;
this.viewportElement.style.setProperty( '--page-height', pageHeight + 'px' );
this.viewportElement.style.scrollSnapType = typeof config.scrollSnap === 'string' ? `y ${config.scrollSnap}` : '';
@@ -333,12 +346,12 @@ export default class ScrollView {
for( let i = 0; i < totalScrollTriggerCount + 1; i++ ) {
const triggerStick = document.createElement( 'div' );
triggerStick.className = 'scroll-snap-point';
triggerStick.style.height = scrollTriggerHeight + 'px';
triggerStick.style.height = this.scrollTriggerHeight + 'px';
triggerStick.style.scrollSnapAlign = useCompactLayout ? 'center' : 'start';
page.pageElement.appendChild( triggerStick );
if( i === 0 ) {
triggerStick.style.marginTop = -scrollTriggerHeight + 'px';
triggerStick.style.marginTop = -this.scrollTriggerHeight + 'px';
}
}
@@ -355,7 +368,7 @@ export default class ScrollView {
}
// Add scroll padding based on how many scroll triggers we have
page.scrollPadding = scrollTriggerHeight * totalScrollTriggerCount;
page.scrollPadding = this.scrollTriggerHeight * totalScrollTriggerCount;
// The total height including scrollable space
page.totalHeight = page.pageHeight + page.scrollPadding;
@@ -425,7 +438,6 @@ export default class ScrollView {
];
const scrollTriggerSegmentSize = ( trigger.range[1] - trigger.range[0] ) / trigger.page.scrollTriggers.length;
// Set the range for each inner scroll trigger
trigger.page.scrollTriggers.forEach( ( scrollTrigger, i ) => {
scrollTrigger.range = [
@@ -462,16 +474,17 @@ export default class ScrollView {
activate: () => {
this.Reveal.fragments.update( -1, page.fragments, slideElement );
}
},
// Triggers for each fragment group
...fragmentGroups.map( ( fragments, i ) => ({
activate: () => {
this.Reveal.fragments.update( i, page.fragments, slideElement );
}
})
)
}
);
// Triggers for each fragment group
fragmentGroups.forEach( ( fragments, i ) => {
page.scrollTriggers.push({
activate: () => {
this.Reveal.fragments.update( i, page.fragments, slideElement );
}
});
} );
}
@@ -699,6 +712,24 @@ export default class ScrollView {
}
/**
* Scroll to the previous page.
*/
prev() {
this.viewportElement.scrollTop -= this.scrollTriggerHeight;
}
/**
* Scroll to the next page.
*/
next() {
this.viewportElement.scrollTop += this.scrollTriggerHeight;
}
/**
* Scrolls the given slide element into view.
*
@@ -801,8 +832,8 @@ export default class ScrollView {
if( page.active ) {
page.active = false;
page.slideElement.classList.remove( 'present' );
page.backgroundElement.classList.remove( 'present' );
if( page.slideElement ) page.slideElement.classList.remove( 'present' );
if( page.backgroundElement ) page.backgroundElement.classList.remove( 'present' );
}

View File

@@ -142,13 +142,15 @@ export default class SlideContent {
// Support comma separated lists of video sources
backgroundVideo.split( ',' ).forEach( source => {
const sourceElement = document.createElement( 'source' );
sourceElement.setAttribute( 'src', source );
let type = getMimeTypeFromFile( source );
if( type ) {
video.innerHTML += `<source src="${source}" type="${type}">`;
}
else {
video.innerHTML += `<source src="${source}">`;
sourceElement.setAttribute( 'type', type );
}
video.appendChild( sourceElement );
} );
backgroundContent.appendChild( video );
@@ -373,8 +375,11 @@ export default class SlideContent {
isVisible = !!closest( event.target, '.present' );
if( isAttachedToDOM && isVisible ) {
event.target.currentTime = 0;
event.target.play();
// Don't restart if media is already playing
if( event.target.paused || event.target.ended ) {
event.target.currentTime = 0;
event.target.play();
}
}
event.target.removeEventListener( 'loadeddata', this.startEmbeddedMedia );

View File

@@ -1,3 +1,10 @@
import {
SLIDE_NUMBER_FORMAT_CURRENT,
SLIDE_NUMBER_FORMAT_CURRENT_SLASH_TOTAL,
SLIDE_NUMBER_FORMAT_HORIZONTAL_DOT_VERTICAL,
SLIDE_NUMBER_FORMAT_HORIZONTAL_SLASH_VERTICAL
} from "../utils/constants";
/**
* Handles the display of reveal.js' optional slide number.
*/
@@ -56,7 +63,7 @@ export default class SlideNumber {
let config = this.Reveal.getConfig();
let value;
let format = 'h.v';
let format = SLIDE_NUMBER_FORMAT_HORIZONTAL_DOT_VERTICAL;
if ( typeof config.slideNumber === 'function' ) {
value = config.slideNumber( slide );
@@ -69,7 +76,7 @@ export default class SlideNumber {
// If there are ONLY vertical slides in this deck, always use
// a flattened slide number
if( !/c/.test( format ) && this.Reveal.getHorizontalSlides().length === 1 ) {
format = 'c';
format = SLIDE_NUMBER_FORMAT_CURRENT;
}
// Offset the current slide number by 1 to make it 1-indexed
@@ -77,16 +84,16 @@ export default class SlideNumber {
value = [];
switch( format ) {
case 'c':
case SLIDE_NUMBER_FORMAT_CURRENT:
value.push( this.Reveal.getSlidePastCount( slide ) + horizontalOffset );
break;
case 'c/t':
case SLIDE_NUMBER_FORMAT_CURRENT_SLASH_TOTAL:
value.push( this.Reveal.getSlidePastCount( slide ) + horizontalOffset, '/', this.Reveal.getTotalSlides() );
break;
default:
let indices = this.Reveal.getIndices( slide );
value.push( indices.h + horizontalOffset );
let sep = format === 'h/v' ? '/' : '.';
let sep = format === SLIDE_NUMBER_FORMAT_HORIZONTAL_SLASH_VERTICAL ? '/' : '.';
if( this.Reveal.isVerticalSlide( slide ) ) value.push( sep, indices.v + 1 );
}
}

View File

@@ -84,7 +84,7 @@ export default class Touch {
isSwipePrevented( target ) {
// Prevent accidental swipes when scrubbing timelines
if( matches( target, 'video, audio' ) ) return true;
if( matches( target, 'video[controls], audio[controls]' ) ) return true;
while( target && typeof target.hasAttribute === 'function' ) {
if( target.hasAttribute( 'data-prevent-swipe' ) ) return true;
@@ -103,6 +103,8 @@ export default class Touch {
*/
onTouchStart( event ) {
this.touchCaptured = false;
if( this.isSwipePrevented( event.target ) ) return true;
this.touchStartX = event.touches[0].clientX;

View File

@@ -28,7 +28,7 @@ import {
} from './utils/constants.js'
// The reveal.js version
export const VERSION = '5.0.1';
export const VERSION = '5.1.0';
/**
* reveal.js
@@ -51,6 +51,9 @@ export default function( revealElement, options ) {
// Configuration defaults, can be overridden at initialization time
let config = {},
// Flags if initialize() has been invoked for this reveal instance
initialized = false,
// Flags if reveal.js is loaded (has dispatched the 'ready' event)
ready = false,
@@ -127,6 +130,8 @@ export default function( revealElement, options ) {
if( !revealElement ) throw 'Unable to find presentation root (<div class="reveal">).';
initialized = true;
// Cache references to key DOM elements
dom.wrapper = revealElement;
dom.slides = revealElement.querySelector( '.slides' );
@@ -185,6 +190,9 @@ export default function( revealElement, options ) {
*/
function start() {
// Don't proceed if this instance has been destroyed
if( initialized === false ) return;
ready = true;
// Remove slides hidden with data-visibility
@@ -604,6 +612,12 @@ export default function( revealElement, options ) {
*/
function destroy() {
initialized = false;
// There's nothing to destroy if this instance hasn't finished
// initializing
if( ready === false ) return;
removeEventListeners();
cancelAutoSlide();
disablePreviewLinks();
@@ -1016,20 +1030,10 @@ export default function( revealElement, options ) {
}
});
}
// Responsively turn on the scroll mode if there is an activation
// width configured. Ignore if we're configured to always be in
// scroll mode.
if( typeof config.scrollActivationWidth === 'number' && config.view !== 'scroll' ) {
if( size.presentationWidth > 0 && size.presentationWidth <= config.scrollActivationWidth ) {
if( !scrollView.isActive() ) scrollView.activate();
}
else {
if( scrollView.isActive() ) scrollView.deactivate();
}
}
}
checkResponsiveScrollView();
dom.viewport.style.setProperty( '--slide-scale', scale );
dom.viewport.style.setProperty( '--viewport-width', viewportWidth + 'px' );
dom.viewport.style.setProperty( '--viewport-height', viewportHeight + 'px' );
@@ -1081,6 +1085,40 @@ export default function( revealElement, options ) {
}
/**
* Responsively activates the scroll mode when we reach the configured
* activation width.
*/
function checkResponsiveScrollView() {
// Only proceed if...
// 1. The DOM is ready
// 2. Layouts aren't disabled via config
// 3. We're not currently printing
// 4. There is a scrollActivationWidth set
// 5. The deck isn't configured to always use the scroll view
if(
dom.wrapper &&
!config.disableLayout &&
!printView.isActive() &&
typeof config.scrollActivationWidth === 'number' &&
config.view !== 'scroll'
) {
const size = getComputedSlideSize();
if( size.presentationWidth > 0 && size.presentationWidth <= config.scrollActivationWidth ) {
if( !scrollView.isActive() ) {
backgrounds.create();
scrollView.activate()
};
}
else {
if( scrollView.isActive() ) scrollView.deactivate();
}
}
}
/**
* Calculates the computed pixel size of our slides. These
* values are based on the width and height configuration
@@ -1219,7 +1257,7 @@ export default function( revealElement, options ) {
/**
* Returns true if we're currently on the last slide in
* the presenation. If the last slide is a stack, we only
* the presentation. If the last slide is a stack, we only
* consider this the last slide if it's at the end of the
* stack.
*/
@@ -1422,6 +1460,9 @@ export default function( revealElement, options ) {
let currentHorizontalSlide = horizontalSlides[ indexh ],
currentVerticalSlides = currentHorizontalSlide.querySelectorAll( 'section' );
// Indicate when we're on a vertical slide
revealElement.classList.toggle( 'is-vertical-slide', currentVerticalSlides.length > 1 );
// Store references to the previous and current slides
currentSlide = currentVerticalSlides[ indexv ] || currentHorizontalSlide;
@@ -2475,6 +2516,9 @@ export default function( revealElement, options ) {
navigationHistory.hasNavigatedHorizontally = true;
// Scroll view navigation is handled independently
if( scrollView.isActive() ) return scrollView.prev();
// Reverse for RTL
if( config.rtl ) {
if( ( overview.isActive() || skipFragments || fragments.next() === false ) && availableRoutes().left ) {
@@ -2492,6 +2536,9 @@ export default function( revealElement, options ) {
navigationHistory.hasNavigatedHorizontally = true;
// Scroll view navigation is handled independently
if( scrollView.isActive() ) return scrollView.next();
// Reverse for RTL
if( config.rtl ) {
if( ( overview.isActive() || skipFragments || fragments.prev() === false ) && availableRoutes().right ) {
@@ -2507,6 +2554,9 @@ export default function( revealElement, options ) {
function navigateUp({skipFragments=false}={}) {
// Scroll view navigation is handled independently
if( scrollView.isActive() ) return scrollView.prev();
// Prioritize hiding fragments
if( ( overview.isActive() || skipFragments || fragments.prev() === false ) && availableRoutes().up ) {
slide( indexh, indexv - 1 );
@@ -2518,6 +2568,9 @@ export default function( revealElement, options ) {
navigationHistory.hasNavigatedVertically = true;
// Scroll view navigation is handled independently
if( scrollView.isActive() ) return scrollView.next();
// Prioritize revealing fragments
if( ( overview.isActive() || skipFragments || fragments.next() === false ) && availableRoutes().down ) {
slide( indexh, indexv + 1 );
@@ -2533,6 +2586,9 @@ export default function( revealElement, options ) {
*/
function navigatePrev({skipFragments=false}={}) {
// Scroll view navigation is handled independently
if( scrollView.isActive() ) return scrollView.prev();
// Prioritize revealing fragments
if( skipFragments || fragments.prev() === false ) {
if( availableRoutes().up ) {
@@ -2556,6 +2612,9 @@ export default function( revealElement, options ) {
let h = indexh - 1;
slide( h, v );
}
else if( config.rtl ) {
navigateRight({skipFragments});
}
else {
navigateLeft({skipFragments});
}
@@ -2572,6 +2631,9 @@ export default function( revealElement, options ) {
navigationHistory.hasNavigatedHorizontally = true;
navigationHistory.hasNavigatedVertically = true;
// Scroll view navigation is handled independently
if( scrollView.isActive() ) return scrollView.next();
// Prioritize revealing fragments
if( skipFragments || fragments.next() === false ) {
@@ -2700,7 +2762,6 @@ export default function( revealElement, options ) {
function onWindowResize( event ) {
layout();
}
/**
@@ -2879,7 +2940,7 @@ export default function( revealElement, options ) {
loadSlide: slideContent.load.bind( slideContent ),
unloadSlide: slideContent.unload.bind( slideContent ),
// Media playback
// Start/stop all media inside of the current slide
startEmbeddedContent: () => slideContent.startEmbeddedContent( currentSlide ),
stopEmbeddedContent: () => slideContent.stopEmbeddedContent( currentSlide, { unloadIframes: false } ),

View File

@@ -44,7 +44,7 @@ export const colorToRgb = ( color ) => {
};
}
let rgba = color.match( /^rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\,\s*([\d]+|[\d]*.[\d]+)\s*\)$/i );
let rgba = color.match( /^rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d]+|[\d]*.[\d]+)\s*\)$/i );
if( rgba ) {
return {
r: parseInt( rgba[1], 10 ),

View File

@@ -2,9 +2,16 @@
export const SLIDES_SELECTOR = '.slides section';
export const HORIZONTAL_SLIDES_SELECTOR = '.slides>section';
export const VERTICAL_SLIDES_SELECTOR = '.slides>section.present>section';
export const HORIZONTAL_BACKGROUNDS_SELECTOR = '.backgrounds>.slide-background';
// Methods that may not be invoked via the postMessage API
export const POST_MESSAGE_METHOD_BLACKLIST = /registerPlugin|registerKeyboardShortcut|addKeyBinding|addEventListener|showPreview/;
// Regex for retrieving the fragment style from a class attribute
export const FRAGMENT_STYLE_REGEX = /fade-(down|up|right|left|out|in-then-out|in-then-semi-out)|semi-fade-out|current-visible|shrink|grow/;
export const FRAGMENT_STYLE_REGEX = /fade-(down|up|right|left|out|in-then-out|in-then-semi-out)|semi-fade-out|current-visible|shrink|grow/;
// Slide number formats
export const SLIDE_NUMBER_FORMAT_HORIZONTAL_DOT_VERTICAL = 'h.v';
export const SLIDE_NUMBER_FORMAT_HORIZONTAL_SLASH_VERTICAL = 'h/v';
export const SLIDE_NUMBER_FORMAT_CURRENT = 'c';
export const SLIDE_NUMBER_FORMAT_CURRENT_SLASH_TOTAL = 'c/t';