|
@@ -507,7 +507,9 @@ var Reveal = (function(){
|
|
};
|
|
};
|
|
|
|
|
|
var element = document.createElement( 'div' );
|
|
var element = document.createElement( 'div' );
|
|
- element.className = 'slide-background';
|
|
|
|
|
|
+
|
|
|
|
+ // Carry over custom classes from the slide to the background
|
|
|
|
+ element.className = 'slide-background ' + slide.className.replace( /present|past|future/, '' );
|
|
|
|
|
|
if( data.background ) {
|
|
if( data.background ) {
|
|
// Auto-wrap image urls in url(...)
|
|
// Auto-wrap image urls in url(...)
|
|
@@ -968,8 +970,6 @@ var Reveal = (function(){
|
|
*/
|
|
*/
|
|
function dispatchEvent( type, args ) {
|
|
function dispatchEvent( type, args ) {
|
|
|
|
|
|
- console.log('event', type);
|
|
|
|
-
|
|
|
|
var event = document.createEvent( 'HTMLEvents', 1, 2 );
|
|
var event = document.createEvent( 'HTMLEvents', 1, 2 );
|
|
event.initEvent( type, true, true );
|
|
event.initEvent( type, true, true );
|
|
extend( event, args );
|
|
extend( event, args );
|
|
@@ -1909,6 +1909,11 @@ var Reveal = (function(){
|
|
viewDistance = isOverview() ? 6 : 1;
|
|
viewDistance = isOverview() ? 6 : 1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Limit view distance on weaker devices
|
|
|
|
+ if( isPrintingPDF() ) {
|
|
|
|
+ viewDistance = Number.MAX_VALUE;
|
|
|
|
+ }
|
|
|
|
+
|
|
for( var x = 0; x < horizontalSlidesLength; x++ ) {
|
|
for( var x = 0; x < horizontalSlidesLength; x++ ) {
|
|
var horizontalSlide = horizontalSlides[x];
|
|
var horizontalSlide = horizontalSlides[x];
|
|
|
|
|
|
@@ -1919,7 +1924,13 @@ var Reveal = (function(){
|
|
distanceX = Math.abs( ( indexh - x ) % ( horizontalSlidesLength - viewDistance ) ) || 0;
|
|
distanceX = Math.abs( ( indexh - x ) % ( horizontalSlidesLength - viewDistance ) ) || 0;
|
|
|
|
|
|
// Show the horizontal slide if it's within the view distance
|
|
// Show the horizontal slide if it's within the view distance
|
|
- horizontalSlide.classList[ distanceX > viewDistance ? 'remove' : 'add' ]( 'visible' );
|
|
|
|
|
|
+ if( distanceX < viewDistance ) {
|
|
|
|
+ horizontalSlide.classList.add( 'visible' );
|
|
|
|
+ loadSlide( horizontalSlide );
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ horizontalSlide.classList.remove( 'visible' );
|
|
|
|
+ }
|
|
|
|
|
|
if( verticalSlidesLength ) {
|
|
if( verticalSlidesLength ) {
|
|
|
|
|
|
@@ -1930,7 +1941,13 @@ var Reveal = (function(){
|
|
|
|
|
|
distanceY = x === indexh ? Math.abs( indexv - y ) : Math.abs( y - oy );
|
|
distanceY = x === indexh ? Math.abs( indexv - y ) : Math.abs( y - oy );
|
|
|
|
|
|
- verticalSlide.classList[ ( distanceX + distanceY ) > viewDistance ? 'remove' : 'add' ]( 'visible' );
|
|
|
|
|
|
+ if( distanceX + distanceY < viewDistance ) {
|
|
|
|
+ verticalSlide.classList.add( 'visible' );
|
|
|
|
+ loadSlide( verticalSlide );
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ verticalSlide.classList.remove( 'visible' );
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -2042,14 +2059,18 @@ var Reveal = (function(){
|
|
// states of their slides (past/present/future)
|
|
// states of their slides (past/present/future)
|
|
toArray( dom.background.childNodes ).forEach( function( backgroundh, h ) {
|
|
toArray( dom.background.childNodes ).forEach( function( backgroundh, h ) {
|
|
|
|
|
|
|
|
+ backgroundh.classList.remove( 'past' );
|
|
|
|
+ backgroundh.classList.remove( 'present' );
|
|
|
|
+ backgroundh.classList.remove( 'future' );
|
|
|
|
+
|
|
if( h < indexh ) {
|
|
if( h < indexh ) {
|
|
- backgroundh.className = 'slide-background ' + horizontalPast;
|
|
|
|
|
|
+ backgroundh.classList.add( horizontalPast );
|
|
}
|
|
}
|
|
else if ( h > indexh ) {
|
|
else if ( h > indexh ) {
|
|
- backgroundh.className = 'slide-background ' + horizontalFuture;
|
|
|
|
|
|
+ backgroundh.classList.add( horizontalFuture );
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- backgroundh.className = 'slide-background present';
|
|
|
|
|
|
+ backgroundh.classList.add( 'present' );
|
|
|
|
|
|
// Store a reference to the current background element
|
|
// Store a reference to the current background element
|
|
currentBackground = backgroundh;
|
|
currentBackground = backgroundh;
|
|
@@ -2058,14 +2079,18 @@ var Reveal = (function(){
|
|
if( includeAll || h === indexh ) {
|
|
if( includeAll || h === indexh ) {
|
|
toArray( backgroundh.querySelectorAll( '.slide-background' ) ).forEach( function( backgroundv, v ) {
|
|
toArray( backgroundh.querySelectorAll( '.slide-background' ) ).forEach( function( backgroundv, v ) {
|
|
|
|
|
|
|
|
+ backgroundv.classList.remove( 'past' );
|
|
|
|
+ backgroundv.classList.remove( 'present' );
|
|
|
|
+ backgroundv.classList.remove( 'future' );
|
|
|
|
+
|
|
if( v < indexv ) {
|
|
if( v < indexv ) {
|
|
- backgroundv.className = 'slide-background past';
|
|
|
|
|
|
+ backgroundv.classList.add( 'past' );
|
|
}
|
|
}
|
|
else if ( v > indexv ) {
|
|
else if ( v > indexv ) {
|
|
- backgroundv.className = 'slide-background future';
|
|
|
|
|
|
+ backgroundv.classList.add( 'future' );
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- backgroundv.className = 'slide-background present';
|
|
|
|
|
|
+ backgroundv.classList.add( 'present' );
|
|
|
|
|
|
// Only if this is the present horizontal and vertical slide
|
|
// Only if this is the present horizontal and vertical slide
|
|
if( h === indexh ) currentBackground = backgroundv;
|
|
if( h === indexh ) currentBackground = backgroundv;
|
|
@@ -2145,6 +2170,37 @@ var Reveal = (function(){
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Loads any content that is set to load lazily (data-src)
|
|
|
|
+ * inside of the given slide.
|
|
|
|
+ */
|
|
|
|
+ function loadSlide( slide ) {
|
|
|
|
+
|
|
|
|
+ // Media elements with data-src attributes
|
|
|
|
+ toArray( slide.querySelectorAll( 'img[data-src], video[data-src], audio[data-src]' ) ).forEach( function( element ) {
|
|
|
|
+ element.setAttribute( 'src', element.getAttribute( 'data-src' ) );
|
|
|
|
+ element.removeAttribute( 'data-src' );
|
|
|
|
+ } );
|
|
|
|
+
|
|
|
|
+ // Media elements with multiple <source>s
|
|
|
|
+ toArray( slide.querySelectorAll( 'video, audio' ) ).forEach( function( media ) {
|
|
|
|
+ var sources = 0;
|
|
|
|
+
|
|
|
|
+ toArray( media.querySelectorAll( 'source[data-src]' ) ).forEach( function( source ) {
|
|
|
|
+ source.setAttribute( 'src', source.getAttribute( 'data-src' ) );
|
|
|
|
+ source.removeAttribute( 'data-src' );
|
|
|
|
+ sources += 1;
|
|
|
|
+ } );
|
|
|
|
+
|
|
|
|
+ // If we rewrote sources for this video/audio element, we need
|
|
|
|
+ // to manually tell it to load from its new origin
|
|
|
|
+ if( sources > 0 ) {
|
|
|
|
+ media.load();
|
|
|
|
+ }
|
|
|
|
+ } );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Determine what available routes there are for navigation.
|
|
* Determine what available routes there are for navigation.
|
|
*
|
|
*
|
|
@@ -2502,8 +2558,17 @@ var Reveal = (function(){
|
|
|
|
|
|
if( typeof state === 'object' ) {
|
|
if( typeof state === 'object' ) {
|
|
slide( deserialize( state.indexh ), deserialize( state.indexv ), deserialize( state.indexf ) );
|
|
slide( deserialize( state.indexh ), deserialize( state.indexv ), deserialize( state.indexf ) );
|
|
- togglePause( deserialize( state.paused ) );
|
|
|
|
- toggleOverview( deserialize( state.overview ) );
|
|
|
|
|
|
+
|
|
|
|
+ var pausedFlag = deserialize( state.paused ),
|
|
|
|
+ overviewFlag = deserialize( state.overview );
|
|
|
|
+
|
|
|
|
+ if( typeof pausedFlag === 'boolean' && pausedFlag !== isPaused() ) {
|
|
|
|
+ togglePause( pausedFlag );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if( typeof overviewFlag === 'boolean' && overviewFlag !== isOverview() ) {
|
|
|
|
+ toggleOverview( overviewFlag );
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|