From 9e89faf08cee399207a5224a1ef8f4618b4207ad Mon Sep 17 00:00:00 2001 From: Frankie Robertson Date: Sun, 31 Jan 2016 17:30:25 +0200 Subject: [PATCH] Change interpolation to cubic ease in/ease out --- src/scrollsnap-polyfill.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/scrollsnap-polyfill.js b/src/scrollsnap-polyfill.js index 9c3714e..1863c3d 100644 --- a/src/scrollsnap-polyfill.js +++ b/src/scrollsnap-polyfill.js @@ -583,8 +583,11 @@ * @param {Number} t timing * @return {Number} easing factor */ - var easeInCubic = function(t) { - return t*t*t; + var easeInOutCubic = function(t) { + t *= 2; + if (t < 1) return t*t*t * 0.5; + t -= 2; + return (t*t*t + 2) * 0.5; }; @@ -600,7 +603,7 @@ if (elapsed > duration) { return end; } - return start + (end - start) * easeInCubic(elapsed / duration); + return start + (end - start) * easeInOutCubic(elapsed / duration); }; // a current animation frame