offset() somewhat slow

offset() somewhat slow


I've been working on some dynamic functionality that requires me to
test the position and dimensions of an element on every mouse move
event. I've found that offset() is somewhat slow, especially due to
all the calls to curCSS. I did some research and found a much faster
way to determine the offset - I tested in IE6, FF2, Safari2, and it
works fine there - not sure about older browsers tho - maybe you guys
can determine whether this has method has problems ...
Number.prototype.NaN0=function(){return isNaN(this)?0:this;}
jQuery.fn.extend( {
offset: function ()
{
var elmt = this[0];
var left = 0;
var top = 0;
while (elmt.offsetParent)
{
left += elmt.offsetLeft + (elmt.currentStyle?
(parseInt(elmt.currentStyle.borderLeftWidth)).NaN0():0);
top += elmt.offsetTop + (elmt.currentStyle?
(parseInt(elmt.currentStyle.borderTopWidth)).NaN0():0);
elmt = elmt.offsetParent;
}
left += elmt.offsetLeft + (elmt.currentStyle?
(parseInt(elmt.currentStyle.borderLeftWidth)).NaN0():0);
top += elmt.offsetTop + (elmt.currentStyle?
(parseInt(elmt.currentStyle.borderTopWidth)).NaN0():0);
return {'left':left, 'top':top};
}
} );