-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjquery.afterresize.js
51 lines (43 loc) · 1.26 KB
/
jquery.afterresize.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*!
* jQuery afterresize event plugin
* http://github.com/roxeteer/jquery-afterresize
*
* Copyright (c) 2010 Visa Kopu, [email protected]
*
* Licensed under the BSD license.
* http://github.com/roxeteer/jquery-afterresize/wiki/License
*/
(function($) {
var resizeHandler = function(e) {
var el = $(this);
if (el.data("resizetimer")) {
window.clearTimeout(el.data("resizetimer"));
}
el.data("resizetimer", window.setTimeout(function() {
el.trigger("afterresize");
}, 300));
}
$.event.special.afterresize = {
add: function(handleObj) {
$(this).bind("resize", resizeHandler);
// apply old event handler
var old_handler = handleObj.handler;
handleObj.handler = function(event) {
return old_handler.apply(this, arguments);
}
},
remove: function(handleObj) {
$(this).unbind("resize", resizeHandler);
}
};
$.fn.extend({
afterresize: function(f) {
if ($.isFunction(f)) {
$(this).bind("afterresize", f);
} else {
$(this).trigger("afterresize");
}
return this;
}
});
})(jQuery);