From 812b802c1cf896f2af44cd87eef63be4ecf98842 Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Thu, 31 Jan 2019 20:13:32 +0100 Subject: [PATCH] resize event tweaks for #2300 --- README.md | 6 ++++-- js/reveal.js | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8439017..b8ad6a0 100644 --- a/README.md +++ b/README.md @@ -994,10 +994,12 @@ Limitations: ### Resize Event -When reveal.js changes the scale of the slides it fires an resize event. You can subscribe to the event to resize your elements accordingly. +When reveal.js changes the scale of the slides it fires a resize event. You can subscribe to the event to resize your elements accordingly. ```javascript -Reveal.addEventListener( 'resize', function( event ) { /* console.log(event.scale,event.oldscale,event.size); */ } ); +Reveal.addEventListener( 'resize', function( event ) { + // event.scale, event.oldScale, event.size +} ); ``` ### postMessage API diff --git a/js/reveal.js b/js/reveal.js index 8d150d8..e146752 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -2097,6 +2097,8 @@ var size = getComputedSlideSize(); + var oldScale = scale; + // Layout the contents of the slides layoutSlideContents( config.width, config.height ); @@ -2104,7 +2106,6 @@ dom.slides.style.height = size.height + 'px'; // Determine scale of content to fit within available space - var oldscale =scale; scale = Math.min( size.presentationWidth / size.width, size.presentationHeight / size.height ); // Respect max/min scale settings @@ -2170,9 +2171,9 @@ } - if( oldscale!==scale ){ + if( oldScale !== scale ) { dispatchEvent( 'resize', { - 'oldscale': oldscale, + 'oldScale': oldScale, 'scale': scale, 'size': size } );