Snugug / eq.js

Lightweight JavaScript powered element queries
http://eqjs.io/
MIT License
527 stars 34 forks source link

Calculating the width of objects #65

Closed LostSenSS closed 8 years ago

LostSenSS commented 8 years ago

This is problem with simultaneous changeover of states in the set of elements during browser resize. When rounding values offsetWidth on certain width some elements go to the next state, while some are not.

A living example: http://jsfiddle.net/LostSenSS/15j004L6/

Screenshot: https://www.dropbox.com/s/ilh7h2skhgpaz2q/15j004L6.png

Possible solution. If instead of

widths.push(nodes[i].offsetWidth);

use

widths.push(nodes[i].getBoundingClientRect().width);

then the problem disappears.