Issue
What are some techniques for listening for layout changes in modern browsers? window.resize
won't work because it only fires when the entire window is resized, not when content changes cause reflow.
Specifically, I'd like to know when:
- An element's available width changes.
- The total height consumed by the in-flow children of an element changes.
Solution
From a similar question How to know when an DOM element moves or is resized, there is a jQuery plugin from Ben Alman that does just this. This plugin uses the same polling approach outlined in Diodeus's answer.
Example from the plugin page:
// Well, try this on for size!
$("#unicorns").resize(function(e){
// do something when #unicorns element resizes
});
Answered By - Chris Calo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.