Firefox sets the last argument of the callback called from setInterval to the how late the callback is in milliseconds. It occurred to me that this could be used to calculate the offset from beginning of animation in correctFrame, instead of calling new Date() every time. I thought this may be a performance enhancement. JavaScript Frame object:: setInterval() method of frame object is used to call a function of JavaScript or to evaluate an expression after the time interval specified in arguments http://www.exforsys.com/tutorials/javascript/javascript-frame-object.htmlHOME |
I created a patch to ext-base.js that uses this argument.
It doesn't seem to have made much difference, but I thought I would post it here. FlashSupport.com - NEW setInterval() and clearInterval():: 5 posts - 2 authors - Last post: Jan 15, 2006myInterval = setInterval(move, 50, circle); This code will execute the move() function every 50 milliseconds, passing it the argument circle http://www.flashsupport.com/forum/topic.asp?TOPIC_ID=79HOME |
Feel free to benchmark it and come to your own conclusions.
--- source/adapter/ext-base.js.orig 2007-11-13 12:32:54.118454600 -0800
+++ source/adapter/ext-base.js 2007-11-13 12:38:00.434875400 -0800
@@ -1624,19 +1623,23 @@
};
- this.run = function() {
+ this.run = function(late) {
for (var i = 0, len = queue.length; i < len; ++i) {
var tween = queue[i];
if (!tween !tween.isAnimated()) {
continue;
}
-
+
if (tween.currentFrame < tween.totalFrames tween.totalFrames === null)
{
tween.currentFrame += 1;
if (tween.useSeconds) {
- correctFrame(tween);
+ if(Ext.isGecko){
+ correctFrame(tween, late);
+ }else{
+ correctFrame(tween);
+ }
}
tween._onTween.fire();
}
@@ -1655,12 +1658,25 @@
return -1;
};
-
- var correctFrame = function(tween) {
+
+ var correctFrame = function(tween, late, state) {
var frames = tween.totalFrames;
var frame = tween.currentFrame;
var expected = (tween.currentFrame * tween.duration * 1000 / tween.totalFrames);
- var elapsed = (new Date() - tween.getStartTime());
+ var elapsed;
+ if (Ext.isGecko){
+ if (tween.currentFrame === 1 ) {
+ tween.elapsed = 0;
+ //firefox has a minium of 10 milliseconds
+ tween.delay = Ext.lib.AnimMgr.delay < 10?10:Ext.lib.AnimMgr.delay;
+ }
+ tween.elapsed += tween.delay + late;
+ elapsed = tween.elapsed;
+ } else {
+ elapsed = (new Date() - tween.getStartTime());
+ }
+
+
var tweak = 0;
if (elapsed < tween.duration * 1000) {
Red Hat's Rough Recovery From CFO Exit
Windows Live Finds a New, Pre-installed Home
|