view sites/all/themes/omega/js/jquery.resizeend.js @ 0:ff03f76ab3fe

initial version
author danieleb <danielebarchiesi@me.com>
date Wed, 21 Aug 2013 18:51:11 +0100
parents
children
line wrap: on
line source
(function ($) {

  'use strict';

  /**
   * Container for the resizeend timeout.
   */
  var resizeTimeout;

  /**
   * Throttled resize event. Fires only once after the resize ended.
   */
  var event = $.event.special.resizeend = {
    setup: function () {
      $(this).bind('resize', event.handler);
    },

    teardown: function () {
      $(this).unbind('resize', event.handler);
    },

    handler: function (e) {
      var context = this;
      if (resizeTimeout) {
        clearTimeout(resizeTimeout);
      }

      resizeTimeout = setTimeout(function () {
        // Set correct event type
        e.type = 'resizeend';
        $.event.handle.apply(context);
      }, 150);
    }
  };

  /**
   * Wrapper for the resizeend event.
   */
  $.fn.resizeend = function (handler) {
    return $(this).bind('resizeend', handler);
  };

})(jQuery);