Gordon,
I would suspect that there is very little you can do to speed up the
processing on 120 elements, but I could be completely wrong on that since I
would not know the first thing to truly increase speed. But I am curious if
something like below would speed it up (not tested):
$.each($('.elemsToAnimate').size(), function(i){
var thisElem = $('.elemsToAnimate')[i];
thisElem.css ({
top : this.offsetTop - parseInt (
thisElem.css ('margin-top'), 10),
left : this.offsetLeft - parseInt
(thisElem.css('margin-left'),10),
width : 100,
height : 100
});
});
It is more or less the same function just change to $.each
On 6/19/07, Gordon <[EMAIL PROTECTED]> wrote:
I am using a loop to initialize some elements for animation (befor
initialization they are allowed to float, but for the animation
process itself their positions need to be absolute). My code is as
follows.
$('.elemsToAnimate').each (function ()
{
var thisElem = $(this);
thisElem.css ({
top : this.offsetTop - parseInt (
thisElem.css ('margin-top'), 10),
left : this.offsetLeft - parseInt
(thisElem.css('margin-left'),
10),
width : 100,
height : 100
});
});
This achieves the desired effect, namely fixing elements that were
previously allowed to float to an absolute position for animating, but
the function runs rather slow. In fact it can take over 4 seconds to
run on a list containing 120 elements.
I could really do with some help finding a speedup, if you have any
tips I'd appreciate hearign them.
--
Benjamin Sterling
http://www.KenzoMedia.com
http://www.KenzoHosting.com