more testing...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2014-02-05 02:00:24 +04:00
parent e6922cc1d3
commit 1e7eec0ab5

View File

@ -484,6 +484,7 @@ function animateElementTo2(elem, to, duration, easing, speed, use_transitions){
left: to.left - from.left, left: to.left - from.left,
} }
/*
// accepts either 'top' or 'left' the rest is passed as closures... // accepts either 'top' or 'left' the rest is passed as closures...
var _shift = function(direction, t){ var _shift = function(direction, t){
var v = direction == 'top' ? 'y' : 'x' var v = direction == 'top' ? 'y' : 'x'
@ -501,6 +502,7 @@ function animateElementTo2(elem, to, duration, easing, speed, use_transitions){
} }
} }
} }
*/
var runner = animationFrameRunner(function(){ var runner = animationFrameRunner(function(){
var t = Date.now() var t = Date.now()
@ -515,8 +517,34 @@ function animateElementTo2(elem, to, duration, easing, speed, use_transitions){
// calculate target position for current step... // calculate target position for current step...
// XXX do propper easing... // XXX do propper easing...
if(speed != null){ if(speed != null){
_shift('top', t) //_shift('top', t)
_shift('left', t) //_shift('left', t)
if(Math.abs(dist.top) >= 1){
dy = ((t - start) * speed.y)
if(Math.abs(dist.top) > Math.abs(dy)){
dist.top -= dy
cur.top = Math.round(cur.top + dy)
// normalize...
cur.top = Math.abs(dist.top) <= 1 ? to.top : cur.top
// calc speed for next step...
speed.y = dist.top / (duration - (t - start))
} else {
cur.top = to.top
}
}
if(Math.abs(dist.left) >= 1){
dx = ((t - start) * speed.x)
if(Math.abs(dist.left) > Math.abs(dx)){
dist.left -= dx
cur.left = Math.round(cur.left + dx)
// normalize...
cur.left = Math.abs(dist.left) <= 1 ? to.left : cur.left
// calc speed for next step...
speed.x = dist.left / (duration - (t - start))
} else {
cur.left = to.left
}
}
// liner speed... // liner speed...
} else { } else {