From f538384d3eea4169220b6141c5791973c4bb6bd7 Mon Sep 17 00:00:00 2001 From: ewan Date: Wed, 19 Feb 2014 11:55:31 +0000 Subject: [PATCH 1/2] Fix _smoothScrolling state at animateTo animation end Update the state of _smoothScrolling state when animateTo animation ends so that the smooth scroll doesn't trigger on the next render loop. --- src/skrollr.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/skrollr.js b/src/skrollr.js index bfda991b..063142b0 100644 --- a/src/skrollr.js +++ b/src/skrollr.js @@ -572,6 +572,10 @@ _scrollAnimation.done.call(_instance, true); } + if(_smoothScrolling) { + _smoothScrolling.targetTop = _instance.getScrollTop(); //Update smooth scroll data so we don't scroll in next _render loop + } + _scrollAnimation = undefined; }; @@ -1006,6 +1010,9 @@ //It's over if(now >= _scrollAnimation.endTime) { renderTop = _scrollAnimation.targetTop; + if(_smoothScrolling) { + _smoothScrolling.targetTop = _instance.getScrollTop(); //Update smooth scroll data so we don't scroll in next _render loop + } afterAnimationCallback = _scrollAnimation.done; _scrollAnimation = undefined; } else { From fe04e204ba4e6c5b97a2cb9a25ce9d986e2cffc7 Mon Sep 17 00:00:00 2001 From: ewan Date: Tue, 4 Mar 2014 16:52:09 +0000 Subject: [PATCH 2/2] Changed which variable to use when updating _smoothScrolling state Apparently the _instance.getScrollTop() doesn't always return the right value so switched to renderTop. --- src/skrollr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/skrollr.js b/src/skrollr.js index 063142b0..2332269f 100644 --- a/src/skrollr.js +++ b/src/skrollr.js @@ -1011,7 +1011,7 @@ if(now >= _scrollAnimation.endTime) { renderTop = _scrollAnimation.targetTop; if(_smoothScrolling) { - _smoothScrolling.targetTop = _instance.getScrollTop(); //Update smooth scroll data so we don't scroll in next _render loop + _smoothScrolling.targetTop = renderTop; //Update smooth scroll data so we don't scroll in next _render loop } afterAnimationCallback = _scrollAnimation.done; _scrollAnimation = undefined;