mirror of
https://github.com/hakimel/reveal.js.git
synced 2025-10-28 20:36:13 +01:00
dispatch slidechange events in reader mode
This commit is contained in:
44
js/reveal.js
44
js/reveal.js
@@ -707,6 +707,26 @@ export default function( revealElement, options ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatches a slidechanged event.
|
||||
*
|
||||
* @param {string} origin Used to identify multiplex clients
|
||||
*/
|
||||
function dispatchSlideChanged( origin ) {
|
||||
|
||||
dispatchEvent({
|
||||
type: 'slidechanged',
|
||||
data: {
|
||||
indexh,
|
||||
indexv,
|
||||
previousSlide,
|
||||
currentSlide,
|
||||
origin
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatched a postMessage of the given type from our window.
|
||||
*/
|
||||
@@ -1440,16 +1460,7 @@ export default function( revealElement, options ) {
|
||||
}
|
||||
|
||||
if( slideChanged ) {
|
||||
dispatchEvent({
|
||||
type: 'slidechanged',
|
||||
data: {
|
||||
indexh,
|
||||
indexv,
|
||||
previousSlide,
|
||||
currentSlide,
|
||||
origin
|
||||
}
|
||||
});
|
||||
dispatchSlideChanged( origin );
|
||||
}
|
||||
|
||||
// Handle embedded content
|
||||
@@ -1494,6 +1505,18 @@ export default function( revealElement, options ) {
|
||||
|
||||
}
|
||||
|
||||
function setCurrentReaderPage( pageIndex, pageElement ) {
|
||||
|
||||
indexh = pageIndex;
|
||||
indexv = 0;
|
||||
|
||||
previousSlide = currentSlide;
|
||||
currentSlide = pageElement.querySelector( 'section' );
|
||||
|
||||
dispatchSlideChanged();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Syncs the presentation with the current DOM. Useful
|
||||
* when new slides or control elements are added or when
|
||||
@@ -2827,6 +2850,7 @@ export default function( revealElement, options ) {
|
||||
registerKeyboardShortcut: keyboard.registerKeyboardShortcut.bind( keyboard ),
|
||||
|
||||
getComputedSlideSize,
|
||||
setCurrentReaderPage,
|
||||
|
||||
// Returns the current scale of the presentation content
|
||||
getScale: () => scale,
|
||||
|
||||
Reference in New Issue
Block a user