A collection of configurable easing functions for Javascript.
See the demo that accompanies this repository for examples of each tween function.
Download the built file and include it in your project. Do not hotlink to this file!
<scriptsrc="easing.js"></script>Then reference the global "easing" variable:
// Pass in a value from 0 - 1 and get the eased value backeasing.easeInCube(0.5);Install with npm install --save easing-utils
// Curly braces needed for importimport{easeInCubic,easeInOutBounce}from'easing-utils';// Pass in a value from 0 - 1 and get the eased value backconsteased=easeInCubic(0.5);Install with npm install --save easing-utils
vareasing=require('easing-utils');// Pass in a value from 0 - 1 and get the eased value backvareased=easing.easeInCubic(0.5);All values are from 0 to 1.
Some functions take an optional magnitude argument. The ranges vary per function, and usually determine how far past zero the tween goes.
First install all dependencies:
npminstallTo build the standalone Javascript file, run:
npmrunbuild-cdnThe output is put in the dist/ folder.
The website deployed here lives in the gh-pages/ folder. To deploy the website, run npm run gh-pages. Then go to http://[your username].github.io/easing-utils/gh-pages/. Out of laziness, I have not yet set up a development server to work on the Github pages.
There's a few other easing libraries out there, but none of them met my needs, which are:
- Fully documented
- Configurable easing functions where available
- Examples presented clearly
- Available through npm
- High quality, readable source code
- Only take a single parameter, which is the initial value from 0 to 1