Skip to content

Instantly share code, notes, and snippets.

@Amitkapadi
Forked from gre/easing.js
Created May 4, 2023 11:11
Show Gist options
  • Save Amitkapadi/cd6d284f49e7edf81e9ca09e1af3a613 to your computer and use it in GitHub Desktop.
Save Amitkapadi/cd6d284f49e7edf81e9ca09e1af3a613 to your computer and use it in GitHub Desktop.

Revisions

  1. @gre gre revised this gist Jan 25, 2023. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions easing.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,8 @@
    /*
    * This work is free. You can redistribute it and/or modify it under the
    * terms of the Do What The Fuck You Want To Public License, Version 2,
    * as published by Sam Hocevar. See the COPYING file for more details.
    */
    /*
    * Easing Functions - inspired from http://gizma.com/easing/
    * only considering the t value for the range [0, 1] => [0, 1]
  2. @gre gre revised this gist Jan 17, 2020. 1 changed file with 13 additions and 13 deletions.
    26 changes: 13 additions & 13 deletions easing.js
    Original file line number Diff line number Diff line change
    @@ -4,29 +4,29 @@
    */
    EasingFunctions = {
    // no easing, no acceleration
    linear: function (t) { return t },
    linear: t => t,
    // accelerating from zero velocity
    easeInQuad: function (t) { return t*t },
    easeInQuad: t => t*t,
    // decelerating to zero velocity
    easeOutQuad: function (t) { return t*(2-t) },
    easeOutQuad: t => t*(2-t),
    // acceleration until halfway, then deceleration
    easeInOutQuad: function (t) { return t<.5 ? 2*t*t : -1+(4-2*t)*t },
    easeInOutQuad: t => t<.5 ? 2*t*t : -1+(4-2*t)*t,
    // accelerating from zero velocity
    easeInCubic: function (t) { return t*t*t },
    easeInCubic: t => t*t*t,
    // decelerating to zero velocity
    easeOutCubic: function (t) { return (--t)*t*t+1 },
    easeOutCubic: t => (--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 },
    easeInOutCubic: t => 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 },
    easeInQuart: t => t*t*t*t,
    // decelerating to zero velocity
    easeOutQuart: function (t) { return 1-(--t)*t*t*t },
    easeOutQuart: t => 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 },
    easeInOutQuart: t => 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 },
    easeInQuint: t => t*t*t*t*t,
    // decelerating to zero velocity
    easeOutQuint: function (t) { return 1+(--t)*t*t*t*t },
    easeOutQuint: t => 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: t => 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 }
    }