From e10ebb49ddac838a1851a3cd03fc561266abc770 Mon Sep 17 00:00:00 2001 From: Oliver Pulges Date: Thu, 20 Mar 2014 12:52:57 +0200 Subject: [PATCH] Width and height are updated incorrectly after orientationchange event --- src/skrollr.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/skrollr.js b/src/skrollr.js index b980cb39..57b8396e 100644 --- a/src/skrollr.js +++ b/src/skrollr.js @@ -290,21 +290,23 @@ //Triggers parsing of elements and a first reflow. _instance.refresh(); + var requestAnimFrame = polyfillRAF(); + _addEvent(window, 'resize orientationchange', function() { - var width = documentElement.clientWidth; - var height = documentElement.clientHeight; + requestAnimFrame(function() { + var width = documentElement.clientWidth; + var height = documentElement.clientHeight; - //Only reflow if the size actually changed (#271). - if(height !== _lastViewportHeight || width !== _lastViewportWidth) { - _lastViewportHeight = height; - _lastViewportWidth = width; + //Only reflow if the size actually changed (#271). + if(height !== _lastViewportHeight || width !== _lastViewportWidth) { + _lastViewportHeight = height; + _lastViewportWidth = width; - _requestReflow = true; - } + _requestReflow = true; + } + }); }); - var requestAnimFrame = polyfillRAF(); - //Let's go. (function animloop(){ _render();