// アニメーション関数
function animate(element, property, from, to, duration, easing) {
var begin = +new Date; // 開始時間
var timer = setInterval(function() {
var time = new Date - begin; // 経過時間
var pos, now;
if (time > duration) {
clearInterval(timer);
now = to;
}
else {
pos = easing(time, duration);
now = pos * (to - from) + from;
}
element.style[property] = now + "px";
}, 10);
}
// イージング関数
function linear(time, duration) {
return time / duration;
}
animate(circle, 'left', 0, 500, 1000, linear);