Skip to content

@ded /tween.js
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
generic time-based tween with easing support
!function ($) {
function tween(duration, from, to, tween, ease) {
ease = ease || function (t) {
return t;
}
var self = this,
time = duration || 1000,
animDiff = to - from,
startTime = new Date(),
timer = setInterval(animate, 5);
function animate () {
var diff = new Date() - startTime;
if (diff > time) {
tween(to);
clearInterval(timer);
timer = null;
return;
}
tween((animDiff * ease(diff / time)) + from);
}
}
$.ender({tween: tween});
}(ender)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.