Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript: Does modifying scrollTop/scrollLeft trigger browser reflow?

I'm wondering if animating the scrollbars with Javascript triggers browser reflow.

Any difference across different browser implementations?

window.pageXOffset & window.pageYOffset
document.documentElement.scrollLeft & document.documentElement.scrollTop
document.body.scrollLeft & document.body.scrollTop

Thanks!

like image 672
Jon Raasch Avatar asked Mar 09 '10 23:03

Jon Raasch


2 Answers

I dug in deeper and found this link which says it does cause reflow: http://www.phpied.com/rendering-repaint-reflowrelayout-restyle/

I also tested it and modifying scrollTop and scrollLeft both trigger reflow (in Firefox at least).

Heh sorry for answering my own question, but hopefully this info is useful for someone :).

like image 86
Jon Raasch Avatar answered Nov 14 '22 07:11

Jon Raasch


According to this question, no.

like image 1
Marcel Korpel Avatar answered Nov 14 '22 08:11

Marcel Korpel