jquery下div 的resize事件示例代碼
更新時(shí)間:2014年03月09日 16:46:02 作者:
這篇文章主要介紹了某位大神寫(xiě)的jquery下div 的resize事件,需要的朋友可以參考下
這是某位大神寫(xiě)的jquery下div 的resize事件。
//resize of div
(function($, h, c) {
var a = $([]),
e = $.resize = $.extend($.resize, {}),
i,
k = "setTimeout",
j = "resize",
d = j + "-special-event",
b = "delay",
f = "throttleWindow";
e[b] = 250;
e[f] = true;
$.event.special[j] = {
setup: function() {
if (!e[f] && this[k]) {
return false;
}
var l = $(this);
a = a.add(l);
$.data(this, d, {
w: l.width(),
h: l.height()
});
if (a.length === 1) {
g();
}
},
teardown: function() {
if (!e[f] && this[k]) {
return false;
}
var l = $(this);
a = a.not(l);
l.removeData(d);
if (!a.length) {
clearTimeout(i);
}
},
add: function(l) {
if (!e[f] && this[k]) {
return false;
}
var n;
function m(s, o, p) {
var q = $(this),
r = $.data(this, d);
r.w = o !== c ? o: q.width();
r.h = p !== c ? p: q.height();
n.apply(this, arguments);
}
if ($.isFunction(l)) {
n = l;
return m;
} else {
n = l.handler;
l.handler = m;
}
}
};
function g() {
i = h[k](function() {
a.each(function() {
var n = $(this),
m = n.width(),
l = n.height(),
o = $.data(this, d);
if (m !== o.w || l !== o.h) {
n.trigger(j, [o.w = m, o.h = l]);
}
});
g();
},
e[b]);
}
})(jQuery, this);
這樣就可以 $('div').resize(fucntion(){ .. }); 了
復(fù)制代碼 代碼如下:
//resize of div
(function($, h, c) {
var a = $([]),
e = $.resize = $.extend($.resize, {}),
i,
k = "setTimeout",
j = "resize",
d = j + "-special-event",
b = "delay",
f = "throttleWindow";
e[b] = 250;
e[f] = true;
$.event.special[j] = {
setup: function() {
if (!e[f] && this[k]) {
return false;
}
var l = $(this);
a = a.add(l);
$.data(this, d, {
w: l.width(),
h: l.height()
});
if (a.length === 1) {
g();
}
},
teardown: function() {
if (!e[f] && this[k]) {
return false;
}
var l = $(this);
a = a.not(l);
l.removeData(d);
if (!a.length) {
clearTimeout(i);
}
},
add: function(l) {
if (!e[f] && this[k]) {
return false;
}
var n;
function m(s, o, p) {
var q = $(this),
r = $.data(this, d);
r.w = o !== c ? o: q.width();
r.h = p !== c ? p: q.height();
n.apply(this, arguments);
}
if ($.isFunction(l)) {
n = l;
return m;
} else {
n = l.handler;
l.handler = m;
}
}
};
function g() {
i = h[k](function() {
a.each(function() {
var n = $(this),
m = n.width(),
l = n.height(),
o = $.data(this, d);
if (m !== o.w || l !== o.h) {
n.trigger(j, [o.w = m, o.h = l]);
}
});
g();
},
e[b]);
}
})(jQuery, this);
這樣就可以 $('div').resize(fucntion(){ .. }); 了
相關(guān)文章
jquery右下角自動(dòng)彈出可關(guān)閉的廣告層
jQuery實(shí)現(xiàn)右下角自動(dòng)彈出可關(guān)閉的懸浮提示層特效。這種效果可以使用jQuery彈出層實(shí)現(xiàn)。有需要的小伙伴可以參考下。2015-05-05輕松實(shí)現(xiàn)jQuery添加刪除按鈕Click事件
這篇文章主要為大家詳細(xì)介紹了如何輕松實(shí)現(xiàn)jQuery添加刪除按鈕Click事件,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-03-03jquery網(wǎng)頁(yè)加載進(jìn)度條的實(shí)現(xiàn)
本篇文章主要介紹了jquery網(wǎng)頁(yè)加載進(jìn)度條的實(shí)現(xiàn) ,在頁(yè)面加載的時(shí)候,上方紅色的進(jìn)度條,有興趣的可以了解一下2017-06-06JQuery 操作Javascript對(duì)象和數(shù)組的工具函數(shù)小結(jié)
JQuery提供了很多實(shí)用的工具函數(shù)。這些函數(shù)主要分為兩類(lèi),操作集合數(shù)組的函數(shù)和非集合數(shù)組函數(shù)。2010-01-01jQuery Dialog 打開(kāi)時(shí)自動(dòng)聚焦的解決方法(兩種方法)
這篇文章主要介紹了jQuery Dialog 打開(kāi)時(shí)自動(dòng)聚焦的解決方法,及jquery dialog打開(kāi)時(shí),自動(dòng)聚焦在第一個(gè)控件上的方法,對(duì)jquery dialog相關(guān)知識(shí)感興趣的朋友通過(guò)本文一起學(xué)習(xí)吧2016-11-11