├── .gitignore ├── LICENSE ├── Makefile ├── bower.json ├── easing-min.js ├── easing.js ├── package.json └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Numerous always-ignore extensions 2 | *.diff 3 | *.err 4 | *.orig 5 | *.log 6 | *.rej 7 | *.swo 8 | *.swp 9 | *.vi 10 | *.cache 11 | *~ 12 | 13 | # OS or Editor folders 14 | .DS_Store 15 | Thumbs.db 16 | .cache 17 | .project 18 | .settings 19 | .tmproj 20 | *.esproj 21 | nbproject 22 | *.sublime-project 23 | *.sublime-workspace 24 | .tm_properties 25 | 26 | # Dreamweaver added files 27 | _notes 28 | dwsync.xml 29 | 30 | # Komodo 31 | *.komodoproject 32 | .komodotools 33 | 34 | # Folders to ignore 35 | .hg 36 | .svn 37 | .CVS 38 | .idea 39 | _assets 40 | tags 41 | intermediate 42 | publish 43 | dist 44 | 45 | # Ignore CSS in common LESS paths 46 | less/*.css 47 | less/*/*.css -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danro/easing-js/4f5e7edbde7f7200a1baf08e357377896c0d207e/LICENSE -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | min: 2 | uglifyjs easing.js > easing-min.js -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "easing", 3 | "version": "0.5.4", 4 | "description": "Generic set of easing functions with AMD support", 5 | "authors": [ 6 | "Dan Rogers " 7 | ], 8 | "license": "MIT", 9 | "keywords": ["animation", "easing", "tween"], 10 | "repository": { 11 | "type": "git", 12 | "url": "git://github.com/danro/easing-js.git" 13 | }, 14 | "ignore": [ 15 | "node_modules" 16 | ], 17 | "dependencies": { 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /easing-min.js: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------- 2 | // easing.js v0.5.4 3 | // Generic set of easing functions with AMD support 4 | // https://github.com/danro/easing-js 5 | // This code may be freely distributed under the MIT license 6 | // http://danro.mit-license.org/ 7 | // -------------------------------------------------- 8 | // All functions adapted from Thomas Fuchs & Jeremy Kahn 9 | // Easing Equations (c) 2003 Robert Penner, BSD license 10 | // https://raw.github.com/danro/easing-js/master/LICENSE 11 | // -------------------------------------------------- 12 | (function(a,b){typeof define=="function"?define(b):typeof module!="undefined"?module.exports=b:this[a]=b})("easing",{easeInQuad:function(a){return Math.pow(a,2)},easeOutQuad:function(a){return-(Math.pow(a-1,2)-1)},easeInOutQuad:function(a){return(a/=.5)<1?.5*Math.pow(a,2):-0.5*((a-=2)*a-2)},easeInCubic:function(a){return Math.pow(a,3)},easeOutCubic:function(a){return Math.pow(a-1,3)+1},easeInOutCubic:function(a){return(a/=.5)<1?.5*Math.pow(a,3):.5*(Math.pow(a-2,3)+2)},easeInQuart:function(a){return Math.pow(a,4)},easeOutQuart:function(a){return-(Math.pow(a-1,4)-1)},easeInOutQuart:function(a){return(a/=.5)<1?.5*Math.pow(a,4):-0.5*((a-=2)*Math.pow(a,3)-2)},easeInQuint:function(a){return Math.pow(a,5)},easeOutQuint:function(a){return Math.pow(a-1,5)+1},easeInOutQuint:function(a){return(a/=.5)<1?.5*Math.pow(a,5):.5*(Math.pow(a-2,5)+2)},easeInSine:function(a){return-Math.cos(a*(Math.PI/2))+1},easeOutSine:function(a){return Math.sin(a*(Math.PI/2))},easeInOutSine:function(a){return-0.5*(Math.cos(Math.PI*a)-1)},easeInExpo:function(a){return a===0?0:Math.pow(2,10*(a-1))},easeOutExpo:function(a){return a===1?1:-Math.pow(2,-10*a)+1},easeInOutExpo:function(a){return a===0?0:a===1?1:(a/=.5)<1?.5*Math.pow(2,10*(a-1)):.5*(-Math.pow(2,-10*--a)+2)},easeInCirc:function(a){return-(Math.sqrt(1-a*a)-1)},easeOutCirc:function(a){return Math.sqrt(1-Math.pow(a-1,2))},easeInOutCirc:function(a){return(a/=.5)<1?-0.5*(Math.sqrt(1-a*a)-1):.5*(Math.sqrt(1-(a-=2)*a)+1)},easeOutBounce:function(a){return a<1/2.75?7.5625*a*a:a<2/2.75?7.5625*(a-=1.5/2.75)*a+.75:a<2.5/2.75?7.5625*(a-=2.25/2.75)*a+.9375:7.5625*(a-=2.625/2.75)*a+.984375},easeInBack:function(a){var b=1.70158;return a*a*((b+1)*a-b)},easeOutBack:function(a){var b=1.70158;return(a-=1)*a*((b+1)*a+b)+1},easeInOutBack:function(a){var b=1.70158;return(a/=.5)<1?.5*a*a*(((b*=1.525)+1)*a-b):.5*((a-=2)*a*(((b*=1.525)+1)*a+b)+2)},elastic:function(a){return-1*Math.pow(4,-8*a)*Math.sin((a*6-1)*2*Math.PI/2)+1},swingFromTo:function(a){var b=1.70158;return(a/=.5)<1?.5*a*a*(((b*=1.525)+1)*a-b):.5*((a-=2)*a*(((b*=1.525)+1)*a+b)+2)},swingFrom:function(a){var b=1.70158;return a*a*((b+1)*a-b)},swingTo:function(a){var b=1.70158;return(a-=1)*a*((b+1)*a+b)+1},bounce:function(a){return a<1/2.75?7.5625*a*a:a<2/2.75?7.5625*(a-=1.5/2.75)*a+.75:a<2.5/2.75?7.5625*(a-=2.25/2.75)*a+.9375:7.5625*(a-=2.625/2.75)*a+.984375},bouncePast:function(a){return a<1/2.75?7.5625*a*a:a<2/2.75?2-(7.5625*(a-=1.5/2.75)*a+.75):a<2.5/2.75?2-(7.5625*(a-=2.25/2.75)*a+.9375):2-(7.5625*(a-=2.625/2.75)*a+.984375)},easeFromTo:function(a){return(a/=.5)<1?.5*Math.pow(a,4):-0.5*((a-=2)*Math.pow(a,3)-2)},easeFrom:function(a){return Math.pow(a,4)},easeTo:function(a){return Math.pow(a,.25)}}); -------------------------------------------------------------------------------- /easing.js: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------- 2 | // easing.js v0.5.4 3 | // Generic set of easing functions with AMD support 4 | // https://github.com/danro/easing-js 5 | // This code may be freely distributed under the MIT license 6 | // http://danro.mit-license.org/ 7 | // -------------------------------------------------- 8 | // All functions adapted from Thomas Fuchs & Jeremy Kahn 9 | // Easing Equations (c) 2003 Robert Penner, BSD license 10 | // https://raw.github.com/danro/easing-js/master/LICENSE 11 | // -------------------------------------------------- 12 | (function (name, definition) { 13 | /*global define module*/ 14 | if (typeof define == 'function') define(definition); 15 | else if (typeof module != 'undefined') module.exports = definition; 16 | else this[name] = definition; 17 | }('easing', { 18 | easeInQuad: function(pos) { 19 | return Math.pow(pos, 2); 20 | }, 21 | 22 | easeOutQuad: function(pos) { 23 | return -(Math.pow((pos-1), 2) -1); 24 | }, 25 | 26 | easeInOutQuad: function(pos) { 27 | if ((pos/=0.5) < 1) return 0.5*Math.pow(pos,2); 28 | return -0.5 * ((pos-=2)*pos - 2); 29 | }, 30 | 31 | easeInCubic: function(pos) { 32 | return Math.pow(pos, 3); 33 | }, 34 | 35 | easeOutCubic: function(pos) { 36 | return (Math.pow((pos-1), 3) +1); 37 | }, 38 | 39 | easeInOutCubic: function(pos) { 40 | if ((pos/=0.5) < 1) return 0.5*Math.pow(pos,3); 41 | return 0.5 * (Math.pow((pos-2),3) + 2); 42 | }, 43 | 44 | easeInQuart: function(pos) { 45 | return Math.pow(pos, 4); 46 | }, 47 | 48 | easeOutQuart: function(pos) { 49 | return -(Math.pow((pos-1), 4) -1); 50 | }, 51 | 52 | easeInOutQuart: function(pos) { 53 | if ((pos/=0.5) < 1) return 0.5*Math.pow(pos,4); 54 | return -0.5 * ((pos-=2)*Math.pow(pos,3) - 2); 55 | }, 56 | 57 | easeInQuint: function(pos) { 58 | return Math.pow(pos, 5); 59 | }, 60 | 61 | easeOutQuint: function(pos) { 62 | return (Math.pow((pos-1), 5) +1); 63 | }, 64 | 65 | easeInOutQuint: function(pos) { 66 | if ((pos/=0.5) < 1) return 0.5*Math.pow(pos,5); 67 | return 0.5 * (Math.pow((pos-2),5) + 2); 68 | }, 69 | 70 | easeInSine: function(pos) { 71 | return -Math.cos(pos * (Math.PI/2)) + 1; 72 | }, 73 | 74 | easeOutSine: function(pos) { 75 | return Math.sin(pos * (Math.PI/2)); 76 | }, 77 | 78 | easeInOutSine: function(pos) { 79 | return (-0.5 * (Math.cos(Math.PI*pos) -1)); 80 | }, 81 | 82 | easeInExpo: function(pos) { 83 | return (pos===0) ? 0 : Math.pow(2, 10 * (pos - 1)); 84 | }, 85 | 86 | easeOutExpo: function(pos) { 87 | return (pos===1) ? 1 : -Math.pow(2, -10 * pos) + 1; 88 | }, 89 | 90 | easeInOutExpo: function(pos) { 91 | if(pos===0) return 0; 92 | if(pos===1) return 1; 93 | if((pos/=0.5) < 1) return 0.5 * Math.pow(2,10 * (pos-1)); 94 | return 0.5 * (-Math.pow(2, -10 * --pos) + 2); 95 | }, 96 | 97 | easeInCirc: function(pos) { 98 | return -(Math.sqrt(1 - (pos*pos)) - 1); 99 | }, 100 | 101 | easeOutCirc: function(pos) { 102 | return Math.sqrt(1 - Math.pow((pos-1), 2)); 103 | }, 104 | 105 | easeInOutCirc: function(pos) { 106 | if((pos/=0.5) < 1) return -0.5 * (Math.sqrt(1 - pos*pos) - 1); 107 | return 0.5 * (Math.sqrt(1 - (pos-=2)*pos) + 1); 108 | }, 109 | 110 | easeOutBounce: function(pos) { 111 | if ((pos) < (1/2.75)) { 112 | return (7.5625*pos*pos); 113 | } else if (pos < (2/2.75)) { 114 | return (7.5625*(pos-=(1.5/2.75))*pos + 0.75); 115 | } else if (pos < (2.5/2.75)) { 116 | return (7.5625*(pos-=(2.25/2.75))*pos + 0.9375); 117 | } else { 118 | return (7.5625*(pos-=(2.625/2.75))*pos + 0.984375); 119 | } 120 | }, 121 | 122 | easeInBack: function(pos) { 123 | var s = 1.70158; 124 | return (pos)*pos*((s+1)*pos - s); 125 | }, 126 | 127 | easeOutBack: function(pos) { 128 | var s = 1.70158; 129 | return (pos=pos-1)*pos*((s+1)*pos + s) + 1; 130 | }, 131 | 132 | easeInOutBack: function(pos) { 133 | var s = 1.70158; 134 | if((pos/=0.5) < 1) return 0.5*(pos*pos*(((s*=(1.525))+1)*pos -s)); 135 | return 0.5*((pos-=2)*pos*(((s*=(1.525))+1)*pos +s) +2); 136 | }, 137 | 138 | elastic: function(pos) { 139 | return -1 * Math.pow(4,-8*pos) * Math.sin((pos*6-1)*(2*Math.PI)/2) + 1; 140 | }, 141 | 142 | swingFromTo: function(pos) { 143 | var s = 1.70158; 144 | return ((pos/=0.5) < 1) ? 0.5*(pos*pos*(((s*=(1.525))+1)*pos - s)) : 145 | 0.5*((pos-=2)*pos*(((s*=(1.525))+1)*pos + s) + 2); 146 | }, 147 | 148 | swingFrom: function(pos) { 149 | var s = 1.70158; 150 | return pos*pos*((s+1)*pos - s); 151 | }, 152 | 153 | swingTo: function(pos) { 154 | var s = 1.70158; 155 | return (pos-=1)*pos*((s+1)*pos + s) + 1; 156 | }, 157 | 158 | bounce: function(pos) { 159 | if (pos < (1/2.75)) { 160 | return (7.5625*pos*pos); 161 | } else if (pos < (2/2.75)) { 162 | return (7.5625*(pos-=(1.5/2.75))*pos + 0.75); 163 | } else if (pos < (2.5/2.75)) { 164 | return (7.5625*(pos-=(2.25/2.75))*pos + 0.9375); 165 | } else { 166 | return (7.5625*(pos-=(2.625/2.75))*pos + 0.984375); 167 | } 168 | }, 169 | 170 | bouncePast: function(pos) { 171 | if (pos < (1/2.75)) { 172 | return (7.5625*pos*pos); 173 | } else if (pos < (2/2.75)) { 174 | return 2 - (7.5625*(pos-=(1.5/2.75))*pos + 0.75); 175 | } else if (pos < (2.5/2.75)) { 176 | return 2 - (7.5625*(pos-=(2.25/2.75))*pos + 0.9375); 177 | } else { 178 | return 2 - (7.5625*(pos-=(2.625/2.75))*pos + 0.984375); 179 | } 180 | }, 181 | 182 | easeFromTo: function(pos) { 183 | if ((pos/=0.5) < 1) return 0.5*Math.pow(pos,4); 184 | return -0.5 * ((pos-=2)*Math.pow(pos,3) - 2); 185 | }, 186 | 187 | easeFrom: function(pos) { 188 | return Math.pow(pos,4); 189 | }, 190 | 191 | easeTo: function(pos) { 192 | return Math.pow(pos,0.25); 193 | } 194 | })); 195 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "easing-js" 3 | , "description": "Generic set of easing functions with AMD support" 4 | , "version": "0.5.4" 5 | , "homepage": "https://github.com/danro/easing-js" 6 | , "author": "Dan Rogers " 7 | , "keywords": ["animation", "easing", "tween"] 8 | , "main": "./easing.js" 9 | , "repository": { 10 | "type": "git" 11 | , "url": "https://github.com/danro/easing-js.git" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # easing.js 2 | 3 | Generic set of easing functions with AMD support. Examples: 4 | 5 | * [Morpheus](https://github.com/ded/morpheus) `morpheus.easings = require('easing');` 6 | * [jQuery](http://jquery.com) `$.extend($.easing, window.easing);` 7 | 8 | 9 | ## Easing Shortcuts 10 | 11 | swingFromTo 12 | swingFrom 13 | swingTo 14 | easeFromTo 15 | easeFrom 16 | easeTo 17 | easeInQuad 18 | easeOutQuad 19 | easeInOutQuad 20 | easeInCubic 21 | easeOutCubic 22 | easeInOutCubic 23 | easeInQuart 24 | easeOutQuart 25 | easeInOutQuart 26 | easeInQuint 27 | easeOutQuint 28 | easeInOutQuint 29 | easeInSine 30 | easeOutSine 31 | easeInOutSine 32 | easeInExpo 33 | easeOutExpo 34 | easeInOutExpo 35 | easeInCirc 36 | easeOutCirc 37 | easeInOutCirc 38 | easeOutBounce 39 | easeInBack 40 | easeOutBack 41 | easeInOutBack 42 | bounce 43 | bouncePast 44 | elastic 45 | 46 | 47 | ## MIT License 48 | 49 | Based on the original [Robert Penner](https://raw.github.com/danro/easing-js/master/LICENSE) equations, and ported over from [Jeremy Kahn's Shifty](https://github.com/jeremyckahn/shifty/) easing methods. 50 | 51 | This code may be freely distributed under the MIT license. 52 | http://danro.mit-license.org/ 53 | --------------------------------------------------------------------------------