prevent repeated autoslidepaused/resumed events

This commit is contained in:
Hakim El Hattab 2014-04-20 10:52:27 +02:00
parent 3795ef1599
commit 4a39aecbab
1 changed files with 14 additions and 8 deletions

View File

@ -968,6 +968,8 @@ 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 );
@ -2747,6 +2749,7 @@ var Reveal = (function(){
function pauseAutoSlide() { function pauseAutoSlide() {
if( autoSlide && !autoSlidePaused ) {
autoSlidePaused = true; autoSlidePaused = true;
dispatchEvent( 'autoslidepaused' ); dispatchEvent( 'autoslidepaused' );
clearTimeout( autoSlideTimeout ); clearTimeout( autoSlideTimeout );
@ -2754,14 +2757,17 @@ var Reveal = (function(){
if( autoSlidePlayer ) { if( autoSlidePlayer ) {
autoSlidePlayer.setPlaying( false ); autoSlidePlayer.setPlaying( false );
} }
}
} }
function resumeAutoSlide() { function resumeAutoSlide() {
if( autoSlide && autoSlidePaused ) {
autoSlidePaused = false; autoSlidePaused = false;
dispatchEvent( 'autoslideresumed' ); dispatchEvent( 'autoslideresumed' );
cueAutoSlide(); cueAutoSlide();
}
} }