megwoo
10/24/2015 - 3:13 AM

Trigger action on window resize

Trigger action on window resize

$(window).resize(function() {
		// stuff
	});
	$(window).trigger('resize');
	
===============

var imgControl = function() {
    $('div.lb_img img').each(function () {
        ... // etc
    });
};

$(document).ready(function () {
    imgControl();
});

$(window).resize(function() {
    imgControl();
});

===============

var resizeTimer;

$(window).on('resize', function(e) {

  clearTimeout(resizeTimer);
  resizeTimer = setTimeout(function() {

    // Run code here, resizing has "stopped"
            
  }, 250);

});