Add pause and play events to autoplay (#713)

This is useful to request pause/resume from other plugins
This commit is contained in:
Guilherme I F L Weizenmann
2019-02-06 08:21:51 -03:00
committed by Henrik Ingo
parent 24e28cc43f
commit 6776a0dab7
2 changed files with 22 additions and 16 deletions

View File

@@ -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 } );
};