diff --git a/js/impress.js b/js/impress.js index cf0d8ff..ea023d9 100644 --- a/js/impress.js +++ b/js/impress.js @@ -1304,6 +1304,16 @@ // triggered for the first slide, so that's where code flow continues. }, false ); + document.addEventListener( "impress:autoplay:pause", function( event ) { + status = "paused"; + reloadTimeout( event ); + }, false ); + + document.addEventListener( "impress:autoplay:play", function( event ) { + status = "playing"; + reloadTimeout( event ); + }, false ); + // If default autoplay time was defined in the presentation root, or // in this step, set timeout. var reloadTimeout = function( event ) { @@ -1342,13 +1352,6 @@ var status = "not clicked"; var toolbarButton = null; - // Copied from core impress.js. Good candidate for moving to a utilities collection. - var triggerEvent = function( el, eventName, detail ) { - var event = document.createEvent( "CustomEvent" ); - event.initCustomEvent( eventName, true, true, detail ); - el.dispatchEvent( event ); - }; - var makeDomElement = function( html ) { var tempDiv = document.createElement( "div" ); tempDiv.innerHTML = html; @@ -1407,7 +1410,7 @@ } } ); - triggerEvent( toolbar, "impress:toolbar:appendChild", + util.triggerEvent( toolbar, "impress:toolbar:appendChild", { group: 10, element: toolbarButton } ); }; diff --git a/src/plugins/autoplay/autoplay.js b/src/plugins/autoplay/autoplay.js index 4c3e8cc..d45b070 100644 --- a/src/plugins/autoplay/autoplay.js +++ b/src/plugins/autoplay/autoplay.js @@ -49,6 +49,16 @@ // triggered for the first slide, so that's where code flow continues. }, false ); + document.addEventListener( "impress:autoplay:pause", function( event ) { + status = "paused"; + reloadTimeout( event ); + }, false ); + + document.addEventListener( "impress:autoplay:play", function( event ) { + status = "playing"; + reloadTimeout( event ); + }, false ); + // If default autoplay time was defined in the presentation root, or // in this step, set timeout. var reloadTimeout = function( event ) { @@ -87,13 +97,6 @@ var status = "not clicked"; var toolbarButton = null; - // Copied from core impress.js. Good candidate for moving to a utilities collection. - var triggerEvent = function( el, eventName, detail ) { - var event = document.createEvent( "CustomEvent" ); - event.initCustomEvent( eventName, true, true, detail ); - el.dispatchEvent( event ); - }; - var makeDomElement = function( html ) { var tempDiv = document.createElement( "div" ); tempDiv.innerHTML = html; @@ -152,7 +155,7 @@ } } ); - triggerEvent( toolbar, "impress:toolbar:appendChild", + util.triggerEvent( toolbar, "impress:toolbar:appendChild", { group: 10, element: toolbarButton } ); };