Skip to content

Commit

Permalink
reorder scale condition; if calculated scale is exactly 1 don't apply…
Browse files Browse the repository at this point in the history
… any scale styles
  • Loading branch information
hakimel committed Nov 8, 2014
1 parent 54e44ef commit 8c76f85
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions js/reveal.js
Original file line number Diff line number Diff line change
Expand Up @@ -1469,16 +1469,23 @@
dom.slides.style.width = size.width + 'px';
dom.slides.style.height = size.height + 'px';

// No point in calculating scale if the only possible
// result is 1
if( scale !== -1 || config.minScale !== 1 || config.maxScale !== 1 ) {
// Determine scale of content to fit within available space
scale = Math.min( size.presentationWidth / size.width, size.presentationHeight / size.height );

// Respect max/min scale settings
scale = Math.max( scale, config.minScale );
scale = Math.min( scale, config.maxScale );

// Determine scale of content to fit within available space
scale = Math.min( size.presentationWidth / size.width, size.presentationHeight / size.height );

// Respect max/min scale settings
scale = Math.max( scale, config.minScale );
scale = Math.min( scale, config.maxScale );

// Don't apply any scaling styles if scale is 1
if( scale === 1 ) {
dom.slides.style.zoom = '';
dom.slides.style.left = '';
dom.slides.style.top = '';
dom.slides.style.bottom = '';
dom.slides.style.right = '';
transformElement( dom.slides, '' );
}
else {
// Prefer zooming in desktop Chrome so that content remains crisp
if( !isMobileDevice && /chrome/i.test( navigator.userAgent ) && typeof dom.slides.style.zoom !== 'undefined' ) {
dom.slides.style.zoom = scale;
Expand Down

0 comments on commit 8c76f85

Please sign in to comment.