Hi
I need to optimize an image gallery slider since a lot of browsers have a hard time dealing with the animations.
Please consider the following example:
var $div1 = $('#div1'),
$div2 = $('#div2'),
$div3 = $('#div3'),
left = 0;
function animate() {
left -= 10;
$div1.css({
left: left + 'px',
width: 1000 - left + 'px'
});
$div2.css( 'left', left - 10 + 'px' );
$div3.css( 'left', left - 40 + 'px' );
}
setInterval( animate, 20 );
This, of course, puts an immense pressure on a lot of browsers and it requires three repaints every 20 ms!
Is there any way to clone the three div's, work on them off-line and them replace ALL of them at once and thereby reduce the amount of repaints to one?
If you have other suggestions, please feel free to share them.
Thanks!