javascript - Detect when a DIV's height changes without polling or mutation observers -


i need height of div , notified when height changes according data.

i using getboundingclientrect() height currently, don't notified of further changes.

i tried domattrmodified , mutationobserver detect changes in data, both of them not universally supported in browsers.

what's best way notifications changes element's height?

the idea (that seems originate blog post on backalleycoder.com) can use

  • onresize on element in ie <=10.
  • scroll events on specially crafted <div> appended child of element in other browsers
  • or onresize on <object style="position: absolute; top: 0; left: 0; height: 100%; width: 100%;"> appended child of element.

there's number of libraries implement or of these approaches:

note older questions here on talk about:

  • attrchange in jquery, domattrmodified, etc. - won't detecting height changes not involve changing height attribute
  • domsubtreemodified, mutationobserver - can used detect changes in content (which 1 of reasons can lead height changes -- other being layout changes, such change width)
  • older solutions, including jquery plugins use polling accomplish -- that's not recommended solution, because page waste user's battery when nothing resized.

[edit] resizeobserver allow detect without hacks in newer browsers.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -