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();