kute.js/README.md
Ingwie Phoenix e2aa72e14b NPM/Bower and UMD support.
- Supports `require()` and `define()` style loading.
- Is available on Bower through Git tags. Not yet via NPM. (run `npm publish` inside the project to do so)
- README updated with hint of usability with module loaders

In the code:
- Implemented UMD method, using AMD in first instance.
- Error is thrown is the root KuteJS could not be found.

What is missing:
- Sub-modules should export their factory rather than doing this on their own.
2015-11-01 21:51:51 +01:00

5 KiB

KUTE.js

A minimal native Javascript tweening engine with jQuery plugin, forked from tween.js with most essential options for web developers, designers and animators. Unlike the original script, KUTE.js delivers easy to use methods to set up high performance animations on the fly.

KUTE.js is like a merge of my own jQueryTween with tween.js, but generally it's a much more smarter build. You link the script at your ending </body> tag and write one line to do just about any animation you can think of.

CDN

Thanks to jsdelivr, we have CDN link here.

NPM/Bower

You can install this through NPM or bower respectively:

$ npm install kute.js
# or
$ bower install kute.js

Basic Usage

At a glance, you can write one line and you're done.

//vanilla js
new KUTE.fromTo('selector', fromValues, toValues, options);

//with jQuery plugin
$('selector').KUTE('fromTo', fromValues, toValues, options);

CommonJS/AMD support

You can use this module through any of the common javascript module systems. For instance:

// NodeJS/CommonJS style
var kute = require("kute.js");
// Add Bezier/Easing...
require("kute.js/kute-bezier");

// AMD
define([
    "kute.js",
    "kute.js/kute-bezier.js"
], function(KUTE){
    // ...
});

Advanced Usage

Quite easily, you can write 'bit more lines and you're making the earth go round.

//vanilla js is always the coolest
KUTE.fromTo(el, {
  //options
    { translate: 0, opacity: 1 }, // fromValues
    { translate: 150, opacity: 0 }, // toValues
    { duration: 500, delay: 0, easing	: 'exponentialInOut', // basic options

      //callbacks
      start: functionOne, // run function when tween starts
      complete: functionTwo, // run function when tween animation is finished
      update: functionThree // run function while tween running    
      stop: functionThree // run function when tween stopped    
      pause: functionThree // run function when tween paused    
      resume: functionThree // run function when resuming tween    
    }
  }
);

Demo

For documentation, examples and other cool tips, check the demo.

#jQuery Plugin That's right, there you have it, just a few bits of code to bridge the awesome kute.js to your jQuery powered projects/apps. The plugin can be found in the /master folder.

What else it does

  • it computes all the values before starting the animation, then caches them to avoid layout thrashing that could occur during animation
  • handles all kinds of transform properties and makes sure to always use the same order of the transform functions (translate, rotate, skew, scale)
  • computes properties' values properly according to their measurement unit (px,%,deg,etc)
  • properly handles cross browser 3D transform with perspective and perspective-origin for element or it's parent
  • converts HEX colors to RGB and tweens the numeric values, then ALWAYS updates color via RGB
  • properly replaces top, centered or any other background position with proper value to be able to tween
  • for most supported properties it reads the current element computed style property value as initial value (via currentStyle || getComputedStyle)
  • because it can read properties values from previous tween animations, KUTE.js can do some awesome chaining with it's .to() method
  • allows you to add many callbacks: start, update, complete, pause, stop, and they can be set as tween options
  • since translate3D is best for movement animation performance, kute.js will always use it
  • accepts "nice & easy string" easing functions, like linear or easingExponentialOut (removes the use of the evil eval, making development safer easier and closer to standards :)
  • uses all 31 Robert Penner's easing functions, as well as bezier and physics easing functions
  • handles browser prefixes for you for transform, perspective, perspective-origin, border-radius and requestAnimationFrame
  • all this is possible with a core script of less than 20k size!

Browser Support

Since most modern browsers can handle pretty much everything, legacy browsers need some help, so give them polyfills. I also packed a small polyfill set with most essential features required by KUTE.js to work, it's called minifill, try it.

Contributions

  • Dav aka @dalisoft contributed a great deal for the performance and functionality of KUTE.js
  • Ingwie Phoenix: RequireJS/CommonJS compatibility and usability with common package managers
  • Others who contribute to the project

License

MIT License