jquery下div 的resize事件示例代碼
更新時間:2014年03月09日 16:46:02 作者:
這篇文章主要介紹了某位大神寫的jquery下div 的resize事件,需要的朋友可以參考下
這是某位大神寫的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實現(xiàn)input數(shù)值增量和減量的方法
這篇文章主要介紹了使用jQuery實現(xiàn)input數(shù)值增量和減量的方法,實例分析了Bootstrap TouchSpin插件的用法,是非常實用的技巧,需要的朋友可以參考下2015-01-01
輕量級jQuery插件slideBox實現(xiàn)帶底欄輪播(焦點圖)代碼
這篇文章主要介紹了輕量級jQuery插件slideBox實現(xiàn)帶底欄輪播(焦點圖)代碼,代碼簡單易懂,非常實用,特此分享腳本之家平臺供大家學(xué)習(xí)2016-03-03
鼠標(biāo)移到導(dǎo)航當(dāng)前位置的LI變色處于選中狀態(tài)
本文所要實現(xiàn)的效果廣泛應(yīng)用于當(dāng)前導(dǎo)航,主要表現(xiàn)為鼠標(biāo)移到導(dǎo)航上面當(dāng)前的LI變色,具體實現(xiàn)如下,感興趣的朋友可以參考下,希望對大家有所幫助2013-08-08
jQuery插件FusionCharts實現(xiàn)的2D面積圖效果示例【附demo源碼下載】
這篇文章主要介紹了jQuery插件FusionCharts實現(xiàn)的2D面積圖效果,結(jié)合完整實例形式分析了FusionCharts繪制2D面積圖的完整步驟與相關(guān)屬性設(shè)置操作技巧,并附帶demo源碼供讀者下載參考,需要的朋友可以參考下2017-03-03
jQuery實現(xiàn)單擊和鼠標(biāo)感應(yīng)事件
這篇文章主要介紹了jQuery實現(xiàn)單擊和鼠標(biāo)感應(yīng)事件的方法的相關(guān)資料,需要的朋友可以參考下2015-02-02
jquery實現(xiàn)限制textarea輸入字數(shù)的方法
這篇文章主要為大家詳細介紹了jquery實現(xiàn)限制textarea輸入字數(shù)的方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-09-09

