소스 검색

resize event tweaks for #2300

Hakim El Hattab 5 년 전
부모
커밋
812b802c1c
2개의 변경된 파일8개의 추가작업 그리고 5개의 파일을 삭제
  1. 4 2
      README.md
  2. 4 3
      js/reveal.js

+ 4 - 2
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

+ 4 - 3
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
 					} );