Skip to content

Instantly share code, notes, and snippets.

@odyssomay
Created October 25, 2012 17:50
Show Gist options
  • Save odyssomay/3954300 to your computer and use it in GitHub Desktop.
Save odyssomay/3954300 to your computer and use it in GitHub Desktop.
rresize: jquery plugin for recursive resizing
/*
* rresize, jquery plugin by Jonathan Fischer Friberg
* https://github.com/odyssomay
*
* Licensed under WTFPL
* http://sam.zoy.org/wtfpl/
*/
/*
* Usage:
* Call .rresize() on a jquery element.
* Then, the 'resize' event will trigger on that element,
* the element's children, the children of those children ... and so on.
*
* This will generate a lot of event triggering, and quickly becomes slow.
* Therefore, you can set the 'stoprresize' property to true on an element.
* The recursion process will not go deeper than that element.
* To set it, run:
* element.data('stoprresize', true);
* Note that element is a jquery object.
*/
(function( $ ) {
$.fn.rresize = function() {
var j_el = $(this);
j_el.trigger('resize');
if(!j_el.data('stoprresize')) {
j_el.children().each(function(i, e) {
$(e).rresize();
});
}
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment