1
0
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:
Hakim El Hattab
2023-09-25 12:32:46 +02:00
parent 4c9cc89566
commit c856fa9db1
2 changed files with 42 additions and 13 deletions

View File

@@ -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,