Add pause and play events to autoplay (#713)
This is useful to request pause/resume from other plugins
This commit is contained in:
committed by
Henrik Ingo
parent
24e28cc43f
commit
6776a0dab7
@@ -1304,6 +1304,16 @@
|
|||||||
// triggered for the first slide, so that's where code flow continues.
|
// triggered for the first slide, so that's where code flow continues.
|
||||||
}, false );
|
}, 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
|
// If default autoplay time was defined in the presentation root, or
|
||||||
// in this step, set timeout.
|
// in this step, set timeout.
|
||||||
var reloadTimeout = function( event ) {
|
var reloadTimeout = function( event ) {
|
||||||
@@ -1342,13 +1352,6 @@
|
|||||||
var status = "not clicked";
|
var status = "not clicked";
|
||||||
var toolbarButton = null;
|
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 makeDomElement = function( html ) {
|
||||||
var tempDiv = document.createElement( "div" );
|
var tempDiv = document.createElement( "div" );
|
||||||
tempDiv.innerHTML = html;
|
tempDiv.innerHTML = html;
|
||||||
@@ -1407,7 +1410,7 @@
|
|||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
triggerEvent( toolbar, "impress:toolbar:appendChild",
|
util.triggerEvent( toolbar, "impress:toolbar:appendChild",
|
||||||
{ group: 10, element: toolbarButton } );
|
{ group: 10, element: toolbarButton } );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,16 @@
|
|||||||
// triggered for the first slide, so that's where code flow continues.
|
// triggered for the first slide, so that's where code flow continues.
|
||||||
}, false );
|
}, 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
|
// If default autoplay time was defined in the presentation root, or
|
||||||
// in this step, set timeout.
|
// in this step, set timeout.
|
||||||
var reloadTimeout = function( event ) {
|
var reloadTimeout = function( event ) {
|
||||||
@@ -87,13 +97,6 @@
|
|||||||
var status = "not clicked";
|
var status = "not clicked";
|
||||||
var toolbarButton = null;
|
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 makeDomElement = function( html ) {
|
||||||
var tempDiv = document.createElement( "div" );
|
var tempDiv = document.createElement( "div" );
|
||||||
tempDiv.innerHTML = html;
|
tempDiv.innerHTML = html;
|
||||||
@@ -152,7 +155,7 @@
|
|||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
triggerEvent( toolbar, "impress:toolbar:appendChild",
|
util.triggerEvent( toolbar, "impress:toolbar:appendChild",
|
||||||
{ group: 10, element: toolbarButton } );
|
{ group: 10, element: toolbarButton } );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user