Fastest is to avoid using setStyle.

For top, this is good enough: element.style.top = value + 'px';

Then again for non-ie browsers, a position: static should work (?),
and an expression could work to emulate. I forgot, though, if
expressions are faster than JS.

On Dec 17, 2:30 pm, Ryan Florence <[email protected]> wrote:
> Actually, once it's set the first time it will continue to be so.  I'm  
> using Element.Pin in a static sidebar class.  So on scroll it pins it,  
> then sets the top position (otherwise it could get pinned out of view  
> if the page was reloaded from a low scroll position).
>
> Ryan Florence
>
> On Dec 17, 2009, at 1:28 PM, Fábio M. Costa wrote:
>
>
>
> > first is better. I mean, the top style will be most of the time !=  
> > from 100px, so it will make more processing most of the times.
> > first is better (again).
>
> > --
> > Fábio Miranda Costa
> > Solucione Sistemas
> > Engenheiro de interfaces
>
> > On Thu, Dec 17, 2009 at 6:23 PM, Ryan Florence  
> > <[email protected]> wrote:
> > Assuming this is in a scroll event, so it gets fired a whole bunch:
>
> > element.setStyle('top', 100);
>
> > or:
>
> > if(element.getStyle('top') != '100px') element.setStyle('top', 100);
>
> > ?
>
> > The first doesn't care, it just sets the style 100 times in a row.
>
> > The second checks if it even needs to set it.
>
> > So is the logic to find out more intense than just doing it anyway?  
> > I imagine it is but I'm often surprised.
>
> > Ryan Florence
>
> > [Introducing MooDocs - become a better developer](http://blog.flobro.com/
> >  )

Reply via email to