A (yet another) cross-browser, event-based, element resize watcher. This is kind of a (improved) fork of sdecima/javascript-detect-element-resize.
See here a demo.
CDN Hosted - jsDelivr
Load Javascript:
<script src="//cdn.jsdelivr.net/watch-element-resize.js/latest/watch-element-resize.min.js"></script>
Download latest release.
var watchResize = new WatchElementResize(['field1', 'field2']);
watchResize.on('resize', function(evt){
console.info(evt);
// the DOM element
var resized_element = evt.element.target;
// the element offset (width, height, top, left)
var offset = evt.element.offset;
// the window dimensions -- just in case you need
var window_size = evt.window;
});
{String|Array<String>|Element|Array<Element>}
String or array of string, DOM node or array of nodes.
watchResize.on('resize', function(evt){
});