Skip to content

Instantly share code, notes, and snippets.

@RienNeVaPlus
Forked from gre/easing.js
Last active June 2, 2024 08:47
Show Gist options
  • Save RienNeVaPlus/768ce89b83d8e778bbb46868fd26901b to your computer and use it in GitHub Desktop.
Save RienNeVaPlus/768ce89b83d8e778bbb46868fd26901b to your computer and use it in GitHub Desktop.

Revisions

  1. RienNeVaPlus revised this gist Aug 1, 2019. No changes.
  2. RienNeVaPlus revised this gist Jul 19, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions easing.js
    Original file line number Diff line number Diff line change
    @@ -5,9 +5,9 @@
    * http://easings.net
    */
    // no easing, no acceleration
    export function easeLinear(t){ return t; }
    export function easeLinear(t){ return t }
    // accelerating from zero velocity
    export function easeInQuad(t){ return t*t; }
    export function easeInQuad(t){ return t*t }
    // decelerating to zero velocity
    export function easeOutQuad(t){ return t*(2-t) }
    // acceleration until halfway, then deceleration
  3. RienNeVaPlus revised this gist Feb 25, 2019. 1 changed file with 31 additions and 31 deletions.
    62 changes: 31 additions & 31 deletions easing.js
    Original file line number Diff line number Diff line change
    @@ -1,32 +1,32 @@
    /*
    * Easing Functions - inspired from http://gizma.com/easing/
    * only considering the t value for the range [0, 1] => [0, 1]
    /**
    * Easing functions
    *
    * https://gist.github.com/gre/1650294
    * http://easings.net
    */
    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 }
    }
    // no easing, no acceleration
    export function easeLinear(t){ return t; }
    // accelerating from zero velocity
    export function easeInQuad(t){ return t*t; }
    // decelerating to zero velocity
    export function easeOutQuad(t){ return t*(2-t) }
    // acceleration until halfway, then deceleration
    export function easeInOutQuad(t) { return t<.5 ? 2*t*t : -1+(4-2*t)*t }
    // accelerating from zero velocity
    export function easeInCubic(t) { return t*t*t }
    // decelerating to zero velocity
    export function easeOutCubic(t) { return (--t)*t*t+1 }
    // acceleration until halfway, then deceleration
    export function easeInOutCubic(t) { return t<.5 ? 4*t*t*t : (t-1)*(2*t-2)*(2*t-2)+1 }
    // accelerating from zero velocity
    export function easeInQuart(t) { return t*t*t*t }
    // decelerating to zero velocity
    export function easeOutQuart(t) { return 1-(--t)*t*t*t }
    // acceleration until halfway, then deceleration
    export function easeInOutQuart(t) { return t<.5 ? 8*t*t*t*t : 1-8*(--t)*t*t*t }
    // accelerating from zero velocity
    export function easeInQuint(t) { return t*t*t*t*t }
    // decelerating to zero velocity
    export function easeOutQuint(t) { return 1+(--t)*t*t*t*t }
    // acceleration until halfway, then deceleration
    export function easeInOutQuint(t) { return t<.5 ? 16*t*t*t*t*t : 1+16*(--t)*t*t*t*t }
  4. @gre gre revised this gist May 11, 2016. No changes.
  5. @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 }
    }