Skip to content

Commit

Permalink
debounce messages from notes -> main window, fixes hakimel#3147
Browse files Browse the repository at this point in the history
  • Loading branch information
hakimel committed Mar 9, 2022
1 parent fc861fc commit 2a239ae
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dist/reveal.esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/reveal.esm.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/reveal.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/reveal.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/controllers/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default class Location {

// The minimum number of milliseconds that must pass between
// calls to history.replaceState
MAX_REPLACE_STATE_FREQUENCY = 250
MAX_REPLACE_STATE_FREQUENCY = 1000

constructor( Reveal ) {

Expand Down
2 changes: 1 addition & 1 deletion plugin/notes/notes.esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion plugin/notes/notes.js

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion plugin/notes/speaker-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -403,13 +403,21 @@ <h4 class="label">Notes</h4>
}
else if( /slidechanged|fragmentshown|fragmenthidden|paused|resumed/.test( data.eventName ) && currentState !== JSON.stringify( data.state ) ) {

window.opener.postMessage( JSON.stringify({ method: 'setState', args: [ data.state ]} ), '*' );
dispatchStateToMainWindow( data.state );

}
}

} );

/**
* Updates the presentation in the main window to match the state
* of the presentation in the notes window.
*/
const dispatchStateToMainWindow = debounce(( state ) => {
window.opener.postMessage( JSON.stringify({ method: 'setState', args: [ state ]} ), '*' );
}, 500);

/**
* Asynchronously calls the Reveal.js API of the main frame.
*/
Expand Down

0 comments on commit 2a239ae

Please sign in to comment.