mirror of
https://github.com/flynx/PortableMag.git
synced 2025-10-28 18:50:08 +00:00
cleaned out some optimizations that cost more than they gained...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
f9c3c87b10
commit
084d8968c7
60
lib/jli.js
60
lib/jli.js
@ -595,7 +595,6 @@ function animateElementTo(elem, to, duration, easing, speed, use_transitions){
|
||||
var start = Date.now()
|
||||
var then = start + duration
|
||||
var from = getElementShift(elem)
|
||||
/*
|
||||
var cur = {
|
||||
top: from.top,
|
||||
left: from.left
|
||||
@ -604,22 +603,6 @@ function animateElementTo(elem, to, duration, easing, speed, use_transitions){
|
||||
top: to.top - from.top,
|
||||
left: to.left - from.left,
|
||||
}
|
||||
*/
|
||||
|
||||
// do var caching...
|
||||
var to_top = to.top
|
||||
var to_left = to.left
|
||||
var from_top = from.top
|
||||
var from_left = from.left
|
||||
var cur_top = from_top
|
||||
var cur_left = from_left
|
||||
var dist_top = to_top - from_top
|
||||
var dist_left = to_left - from_left
|
||||
if(speed != null){
|
||||
var speed_x = speed.x
|
||||
var speed_y = speed.y
|
||||
}
|
||||
|
||||
|
||||
// XXX are we using this...
|
||||
elem.animating = true
|
||||
@ -642,47 +625,6 @@ function animateElementTo(elem, to, duration, easing, speed, use_transitions){
|
||||
return
|
||||
}
|
||||
|
||||
if(speed != null){
|
||||
// NOTE: these are inlined here for speed...
|
||||
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...
|
||||
} else {
|
||||
var r = (t - start) / duration
|
||||
cur_top = Math.round(from_top + (dist_top * r))
|
||||
cur_left = Math.round(from_left + (dist_left * r))
|
||||
}
|
||||
// do the actual move...
|
||||
setElementTransform(elem, {
|
||||
top: cur_top,
|
||||
left: cur_left
|
||||
})
|
||||
/*
|
||||
// animate a step with speed...
|
||||
if(speed != null){
|
||||
// NOTE: these are almost identical, they are inlined
|
||||
@ -721,8 +663,6 @@ function animateElementTo(elem, to, duration, easing, speed, use_transitions){
|
||||
cur.left = Math.round(from.left + (dist.left * r))
|
||||
}
|
||||
setElementTransform(elem, cur)
|
||||
*/
|
||||
|
||||
// sched next frame...
|
||||
elem.next_frame = getAnimationFrame(animate)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user