sdecima / javascript-detect-element-resize

A Cross-Browser, Event-based, Element Resize Detection
MIT License
881 stars 151 forks source link

use mutation observers in non-IE browsers #1

Closed Mottie closed 10 years ago

Mottie commented 10 years ago

Currently, only IE11+ can use mutation observers.

sdecima commented 10 years ago

With Mutation Observers you can not properly detect all possible size changes of an arbitrary element, and that is why I didn't implement Mutation Observers for any Browser but IE11. The most common case where Mutation Observers does not detect a size change is where the change is originated from a CSS rule, like a CSS pseudo class; e.g. :hover or CSS 3 animations.

In fact, I did implement Mutation Observers for all supported browsers in version 3 of the libraries and I had to step back to only use them on IE11 in version 4 (check out the release notes).

If I use Mutation Observers on, say Chrome or Firefox, then the library would not detect those mentioned size changes. Instead with the current implementation (using overflow and underflow events on supported browsers and 'resize' event on IE10 and below) all browsers (except IE11) detect all possible size changes, and through events.

Maybe I should make that more clear on the README.md

Mottie commented 10 years ago

Oh, sorry, I didn't read the release notes, just everything above that :(