From b0a139ef81aaa73a5227b5ac47b6caf8f58d359d Mon Sep 17 00:00:00 2001 From: Bartek Szopka Date: Sat, 10 Mar 2012 22:51:20 +0000 Subject: [PATCH] "removed unnecessary transitions and jumpiness when presentation starts" --- js/impress.js | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/js/impress.js b/js/impress.js index bf824e2..8498cc6 100644 --- a/js/impress.js +++ b/js/impress.js @@ -112,6 +112,22 @@ return byId( window.location.hash.replace(/^#\/?/,"") ); }; + var computeWindowScale = function ( config ) { + var hScale = window.innerHeight / config.height, + wScale = window.innerWidth / config.width, + scale = hScale > wScale ? wScale : hScale; + + if (config.maxScale && scale > config.maxScale) { + scale = config.maxScale; + } + + if (config.minScale && scale < config.minScale) { + scale = config.minScale; + } + + return scale; + }; + // CHECK SUPPORT var body = document.body; @@ -199,6 +215,8 @@ var steps = $$(".step", root); + var windowScale = computeWindowScale( config ); + // SETUP // set initial values and defaults @@ -220,7 +238,7 @@ css(root, { top: "50%", left: "50%", - transform: perspective( config.perspective ) + transform: perspective( config.perspective/windowScale ) + scale( windowScale ) }); css(canvas, props); @@ -236,22 +254,6 @@ return !!(el && el.id && stepData["impress-" + el.id]); }; - var computeWindowScale = function () { - var hScale = window.innerHeight / config.height, - wScale = window.innerWidth / config.width, - scale = hScale > wScale ? wScale : hScale; - - if (config.maxScale && scale > config.maxScale) { - scale = config.maxScale; - } - - if (config.minScale && scale < config.minScale) { - scale = config.minScale; - } - - return scale; - }; - steps.forEach(function ( el, idx ) { var data = el.dataset, step = { @@ -285,7 +287,7 @@ }); }); - + var active = null; // step events @@ -309,7 +311,6 @@ triggerEvent(step, "impressStepLeave"); } }; - // transitionEnd event handler @@ -325,8 +326,6 @@ root.addEventListener(transitionEnd, onTransitionEnd, false); canvas.addEventListener(transitionEnd, onTransitionEnd, false); - var windowScale = computeWindowScale(); - var stepTo = function ( el, force ) { if ( !isStep(el) || (el === active && !force) ) { // selected element is not defined as step or is already active