A minimal native Javascript tweening engine with jQuery plugin, forked from tween.js. Since most of web developers don't actually use yoyo
, repeat
, play
/pause
/resume
/timeline
/whatever or tweening array values (processed with array interpolation functions), I've removed them, for simplicity and performance.
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.
Also worth noting that the script does it's job without any dependency like plugins or other functionality.
Thanks to jsdelivr, we have CDN link here.
At a glance, you can write one line and you're done.
//vanilla js
new KUTE.Animate(el,options);
//with jQuery plugin
$('selector').Kute(options);
Quite easily, you can write 'bit more lines and you're making the earth go round.
//vanilla js
new KUTE.Animate(el, {
//options
from : {
translate: {x:0},
opacity: 1
},
to : {
translate: {x:150},
opacity: 0
},
duration: 500,
delay : 0,
easing : 'exponentialInOut',
start : functionOne, // run function when tween starts
finish : functionTwo, // run function when tween finishes
special : functionThree // run function while tween runing
}
);
//with jQuery plugin
$('selector').Kute({
//options
from : {
translate: {x:0},
opacity: 1
},
to : {
translate: {x:150},
opacity: 0
},
duration: 500,
delay : 0,
easing : 'exponentialInOut',
start : functionOne, // run function when tween starts
finish : functionTwo, // run function when tween finishes
special : functionThree // run function while tween runing
}
);
It does most of the animation work you need. Supported properties:
- size:
width
andheight
- colors: text
color
andbackgroundColor
(accepts values as HEX, RGB, RGBA, but the output color is always HEX ) - transform:
translate3D
,scale
,rotateX
,rotateY
,rotateZ
(not using rotate3D because processing values are quite a hustle) - position:
top
,left
(ideal for IE9- translate3D(left,top,0) fallback, they require proper use ofposition: relative
and/orposition: absolute
) - zoom: for scale fallback on IE8
backgroundPosition
- window
scroll
This distribution is slightly lighter and more suitable for most projects. It covers:
- size:
width
andheight
- transform:
translate3D
,scale
,rotateX
,rotateY
,rotateZ
- position:
top
,left
(see above for more info on the properties) zoom
: forscale
fallback on IE8- window
scroll
#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 /dist folder.
- computes option values properly according to their measurement unit (px,%,deg,etc)
- properly handles IE10+ 3D
transform
when elements have aperspective
, else the animation won't run - it converts
RGBA
&HEX
colors toRGB
and tweens the inner values, then ALWAYS updates color viaHEX
; no support forRGBA
- 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 style property value as initial value (via
currentStyle || getComputedStyle
) - allows you to add 3 different callbacks:
start
,special
,finish
, and they can be set as tween options (so no more nested functions are invoked as object attributes) - since
translate3D
is best for performance,kute.js
will always uses it - accepts "nice & easy string" easing functions, like
linear
orexponentialOut
(removes the use of the evileval
, making development, safer easier and closer to development standards :) - uses 31 easing functions, all Robert Penner's easing equations
- like mentioned above, for IE8
zoom
is used fortransform: scale(0.5)
, it's not perfect as the object moves from it's floating point to the middle, and some left & top adjustments can be done, but to keep it simple and performance driven, I leave it as is, it's better than nothing. - generally it's using for
-webkit-
prefix for Safari and older webkit browsers for CSS powered transitions.
Since most modern browsers can handle pretty much everything, legacy browsers need some help, so give them polyfills.io. Also kute.js
needs to know when doing stuff for IE9- like my other scripts here, I highy recommend Paul Irish's conditional stylesheets guides to add ie ie[version]
to your site's HTML tag.
coming soon..