Skip to content

Instantly share code, notes, and snippets.

@eeropic
Forked from gre/easing.js
Last active September 27, 2017 16:19
Show Gist options
  • Select an option

  • Save eeropic/dd7e5054dbe039b63307ee8e1d0c2ad4 to your computer and use it in GitHub Desktop.

Select an option

Save eeropic/dd7e5054dbe039b63307ee8e1d0c2ad4 to your computer and use it in GitHub Desktop.

Revisions

  1. eeropic revised this gist Sep 27, 2017. 1 changed file with 38 additions and 0 deletions.
    38 changes: 38 additions & 0 deletions test.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    /*
    * Easing Functions - inspired from http://gizma.com/easing/
    * only considering the t value for the range [0, 1] => [0, 1]
    */
    EasingFunctions = {
    // no easing, no acceleration
    linear: function (t) { return t },
    // accelerating from zero velocity
    easeInSin: function (t) {return 1 + Math.sin(Math.PI / 2 * t - Math.PI / 2)},
    easeOutSin : function (t) {return Math.sin(Math.PI / 2 * t)},
    easeInOutSin: function (t) {return (1 + Math.sin(Math.PI * t - Math.PI / 2))/2},

    easeInQuad: function (t) { return t*t },
    // decelerating to zero velocity
    easeOutQuad: function (t) { return t*(2-t) },
    // acceleration until halfway, then deceleration
    easeInOutQuad: function (t) { return t<.5 ? 2*t*t : -1+(4-2*t)*t },
    // accelerating from zero velocity
    easeInCubic: function (t) { return t*t*t },
    // decelerating to zero velocity
    easeOutCubic: function (t) { return (--t)*t*t+1 },
    // acceleration until halfway, then deceleration
    easeInOutCubic: function (t) { return t<.5 ? 4*t*t*t : (t-1)*(2*t-2)*(2*t-2)+1 },
    // accelerating from zero velocity
    easeInQuart: function (t) { return t*t*t*t },
    // decelerating to zero velocity
    easeOutQuart: function (t) { return 1-(--t)*t*t*t },
    // acceleration until halfway, then deceleration
    easeInOutQuart: function (t) { return t<.5 ? 8*t*t*t*t : 1-8*(--t)*t*t*t },
    // accelerating from zero velocity
    easeInQuint: function (t) { return t*t*t*t*t },
    // decelerating to zero velocity
    easeOutQuint: function (t) { return 1+(--t)*t*t*t*t },
    // acceleration until halfway, then deceleration
    easeInOutQuint: function (t) { return t<.5 ? 16*t*t*t*t*t : 1+16*(--t)*t*t*t*t},


    }
  2. eeropic revised this gist Jun 13, 2017. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion easing.js
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,10 @@ EasingFunctions = {
    // no easing, no acceleration
    linear: function (t) { return t },
    // accelerating from zero velocity
    easeInSin: function (t) {return 1 + Math.sin(Math.PI / 2 * t - Math.PI / 2)},
    easeOutSin : function (t) {return Math.sin(Math.PI / 2 * t)},
    easeInOutSin: function (t) {return (1 + Math.sin(Math.PI * t - Math.PI / 2))/2},

    easeInQuad: function (t) { return t*t },
    // decelerating to zero velocity
    easeOutQuad: function (t) { return t*(2-t) },
    @@ -28,5 +32,7 @@ EasingFunctions = {
    // decelerating to zero velocity
    easeOutQuint: function (t) { return 1+(--t)*t*t*t*t },
    // acceleration until halfway, then deceleration
    easeInOutQuint: function (t) { return t<.5 ? 16*t*t*t*t*t : 1+16*(--t)*t*t*t*t }
    easeInOutQuint: function (t) { return t<.5 ? 16*t*t*t*t*t : 1+16*(--t)*t*t*t*t},


    }
  3. @gre gre revised this gist May 11, 2016. No changes.
  4. @invalid-email-address Anonymous created this gist Jan 20, 2012.
    32 changes: 32 additions & 0 deletions easing.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    /*
    * Easing Functions - inspired from http://gizma.com/easing/
    * only considering the t value for the range [0, 1] => [0, 1]
    */
    EasingFunctions = {
    // no easing, no acceleration
    linear: function (t) { return t },
    // accelerating from zero velocity
    easeInQuad: function (t) { return t*t },
    // decelerating to zero velocity
    easeOutQuad: function (t) { return t*(2-t) },
    // acceleration until halfway, then deceleration
    easeInOutQuad: function (t) { return t<.5 ? 2*t*t : -1+(4-2*t)*t },
    // accelerating from zero velocity
    easeInCubic: function (t) { return t*t*t },
    // decelerating to zero velocity
    easeOutCubic: function (t) { return (--t)*t*t+1 },
    // acceleration until halfway, then deceleration
    easeInOutCubic: function (t) { return t<.5 ? 4*t*t*t : (t-1)*(2*t-2)*(2*t-2)+1 },
    // accelerating from zero velocity
    easeInQuart: function (t) { return t*t*t*t },
    // decelerating to zero velocity
    easeOutQuart: function (t) { return 1-(--t)*t*t*t },
    // acceleration until halfway, then deceleration
    easeInOutQuart: function (t) { return t<.5 ? 8*t*t*t*t : 1-8*(--t)*t*t*t },
    // accelerating from zero velocity
    easeInQuint: function (t) { return t*t*t*t*t },
    // decelerating to zero velocity
    easeOutQuint: function (t) { return 1+(--t)*t*t*t*t },
    // acceleration until halfway, then deceleration
    easeInOutQuint: function (t) { return t<.5 ? 16*t*t*t*t*t : 1+16*(--t)*t*t*t*t }
    }