fix error with removal of control button and progress bar event listeners (closes #323)
This commit is contained in:
parent
d182235f1f
commit
9b830131f7
58
js/reveal.js
58
js/reveal.js
|
@ -404,17 +404,17 @@ var Reveal = (function(){
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( config.progress && dom.progress ) {
|
if ( config.progress && dom.progress ) {
|
||||||
dom.progress.addEventListener( 'click', preventAndForward( onProgressClick ), false );
|
dom.progress.addEventListener( 'click', onProgressClicked, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( config.controls && dom.controls ) {
|
if ( config.controls && dom.controls ) {
|
||||||
var actionEvent = 'ontouchstart' in window ? 'touchstart' : 'click';
|
var actionEvent = 'ontouchstart' in window ? 'touchstart' : 'click';
|
||||||
dom.controlsLeft.forEach( function( el ) { el.addEventListener( actionEvent, preventAndForward( navigateLeft ), false ); } );
|
dom.controlsLeft.forEach( function( el ) { el.addEventListener( actionEvent, onNavigateLeftClicked, false ); } );
|
||||||
dom.controlsRight.forEach( function( el ) { el.addEventListener( actionEvent, preventAndForward( navigateRight ), false ); } );
|
dom.controlsRight.forEach( function( el ) { el.addEventListener( actionEvent, onNavigateRightClicked, false ); } );
|
||||||
dom.controlsUp.forEach( function( el ) { el.addEventListener( actionEvent, preventAndForward( navigateUp ), false ); } );
|
dom.controlsUp.forEach( function( el ) { el.addEventListener( actionEvent, onNavigateUpClicked, false ); } );
|
||||||
dom.controlsDown.forEach( function( el ) { el.addEventListener( actionEvent, preventAndForward( navigateDown ), false ); } );
|
dom.controlsDown.forEach( function( el ) { el.addEventListener( actionEvent, onNavigateDownClicked, false ); } );
|
||||||
dom.controlsPrev.forEach( function( el ) { el.addEventListener( actionEvent, preventAndForward( navigatePrev ), false ); } );
|
dom.controlsPrev.forEach( function( el ) { el.addEventListener( actionEvent, onNavigatePrevClicked, false ); } );
|
||||||
dom.controlsNext.forEach( function( el ) { el.addEventListener( actionEvent, preventAndForward( navigateNext ), false ); } );
|
dom.controlsNext.forEach( function( el ) { el.addEventListener( actionEvent, onNavigateNextClicked, false ); } );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -435,17 +435,17 @@ var Reveal = (function(){
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( config.progress && dom.progress ) {
|
if ( config.progress && dom.progress ) {
|
||||||
dom.progress.removeEventListener( 'click', preventAndForward( onProgressClick ), false );
|
dom.progress.removeEventListener( 'click', onProgressClicked, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( config.controls && dom.controls ) {
|
if ( config.controls && dom.controls ) {
|
||||||
var actionEvent = 'ontouchstart' in window ? 'touchstart' : 'click';
|
var actionEvent = 'ontouchstart' in window ? 'touchstart' : 'click';
|
||||||
dom.controlsLeft.forEach( function( el ) { el.removeEventListener( actionEvent, preventAndForward( navigateLeft ), false ); } );
|
dom.controlsLeft.forEach( function( el ) { el.removeEventListener( actionEvent, onNavigateLeftClicked, false ); } );
|
||||||
dom.controlsRight.forEach( function( el ) { el.removeEventListener( actionEvent, preventAndForward( navigateRight ), false ); } );
|
dom.controlsRight.forEach( function( el ) { el.removeEventListener( actionEvent, onNavigateRightClicked, false ); } );
|
||||||
dom.controlsUp.forEach( function( el ) { el.removeEventListener( actionEvent, preventAndForward( navigateUp ), false ); } );
|
dom.controlsUp.forEach( function( el ) { el.removeEventListener( actionEvent, onNavigateUpClicked, false ); } );
|
||||||
dom.controlsDown.forEach( function( el ) { el.removeEventListener( actionEvent, preventAndForward( navigateDown ), false ); } );
|
dom.controlsDown.forEach( function( el ) { el.removeEventListener( actionEvent, onNavigateDownClicked, false ); } );
|
||||||
dom.controlsPrev.forEach( function( el ) { el.removeEventListener( actionEvent, preventAndForward( navigatePrev ), false ); } );
|
dom.controlsPrev.forEach( function( el ) { el.removeEventListener( actionEvent, onNavigatePrevClicked, false ); } );
|
||||||
dom.controlsNext.forEach( function( el ) { el.removeEventListener( actionEvent, preventAndForward( navigateNext ), false ); } );
|
dom.controlsNext.forEach( function( el ) { el.removeEventListener( actionEvent, onNavigateNextClicked, false ); } );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -487,22 +487,6 @@ var Reveal = (function(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Prevents an events defaults behavior calls the
|
|
||||||
* specified delegate.
|
|
||||||
*
|
|
||||||
* @param {Function} delegate The method to call
|
|
||||||
* after the wrapper has been executed
|
|
||||||
*/
|
|
||||||
function preventAndForward( delegate ) {
|
|
||||||
|
|
||||||
return function( event ) {
|
|
||||||
event.preventDefault();
|
|
||||||
delegate.call( null, event );
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Causes the address bar to hide on mobile devices,
|
* Causes the address bar to hide on mobile devices,
|
||||||
* more vertical space ftw.
|
* more vertical space ftw.
|
||||||
|
@ -1733,7 +1717,9 @@ var Reveal = (function(){
|
||||||
*
|
*
|
||||||
* ( clickX / presentationWidth ) * numberOfSlides
|
* ( clickX / presentationWidth ) * numberOfSlides
|
||||||
*/
|
*/
|
||||||
function onProgressClick( event ) {
|
function onProgressClicked( event ) {
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
var slidesTotal = toArray( document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ).length;
|
var slidesTotal = toArray( document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ).length;
|
||||||
var slideIndex = Math.floor( ( event.clientX / dom.wrapper.offsetWidth ) * slidesTotal );
|
var slideIndex = Math.floor( ( event.clientX / dom.wrapper.offsetWidth ) * slidesTotal );
|
||||||
|
@ -1742,6 +1728,16 @@ var Reveal = (function(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event handles for navigation control buttons.
|
||||||
|
*/
|
||||||
|
function onNavigateLeftClicked( event ) { event.preventDefault(); navigateLeft(); }
|
||||||
|
function onNavigateRightClicked( event ) { event.preventDefault(); navigateRight(); }
|
||||||
|
function onNavigateUpClicked( event ) { event.preventDefault(); navigateUp(); }
|
||||||
|
function onNavigateDownClicked( event ) { event.preventDefault(); navigateDown(); }
|
||||||
|
function onNavigatePrevClicked( event ) { event.preventDefault(); navigatePrev(); }
|
||||||
|
function onNavigateNextClicked( event ) { event.preventDefault(); navigateNext(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for the window level 'hashchange' event.
|
* Handler for the window level 'hashchange' event.
|
||||||
*/
|
*/
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue