marcj / css-element-queries

CSS Element-Queries aka Container Queries. High-speed element dimension/media queries in valid css.
http://marcj.github.io/css-element-queries/
MIT License
4.27k stars 487 forks source link

Removed dirty checking, minor optimizations #135

Closed luzat closed 7 years ago

luzat commented 8 years ago

An update will now only be queued through requestAnimationFrame whenever changes occurred. This means that absolutely no code is running when the page is idling (helpful for power saving and scalability). Care was taken to first read from the DOM and afterwards update it in the new scroll handler to prevent any possible layout thrashing as described here:

http://wilsonpage.co.uk/preventing-layout-thrashing/

lastWidth, lastHeight and all sensor properties are only updated once every frame.

luzat commented 8 years ago

Commit cd5bda1 and the fix in dd75317 change semantics slightly in that updates which are reverted before the next frame will not invoke handlers.

marcj commented 7 years ago

Nice addition, thanks!