色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

用jquery實現(xiàn)等比例縮放圖片效果插件

復(fù)制代碼 代碼如下:
jQuery.fn.autoZoomLoadImage = function(scaling, width, height, loadPic) {
if (loadPic == null) loadPic = "Loading.gif";
return this.each(function() {
var t = $(this);
var src = $(this).attr("src");
var img = new Image();
//alert("Loading")
img.src = src;
//自動縮放圖片
var autoScaling = function() {
if (scaling) {
if (img.width > 0 && img.height > 0) {
if (img.width / img.height >= width / height) {
if (img.width > width) {
t.width(width);
t.height((img.height * width) / img.width);
}
else {
t.width(img.width);
t.height(img.height);
}
}
else {
if (img.height > height) {
t.height(height);
t.width((img.width * height) / img.height);
}
else {
t.width(img.width);
t.height(img.height);
}
}
}
}
}
//處理ff下會自動讀取緩存圖片
if (img.complete) {
//alert("getToCache!");
autoScaling();
return;
}
$(this).attr("src", "");
var loading = $("<img alt=/"加載中/" title=/"圖片加載中/" src=/"" + loadPic + "/" />");
t.hide();
t.after(loading);
$(img).load(function() {
autoScaling();
loading.remove();
t.attr("src", this.src);
t.show();
//alert("finally!")
});
});
}

JavaScript技術(shù)用jquery實現(xiàn)等比例縮放圖片效果插件,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 万源市| 浦城县| 衡阳市| 金乡县| 海安县| 冀州市| 蒙山县| 郎溪县| 霍邱县| 东乌| 义马市| 吐鲁番市| 聂拉木县| 阳曲县| 开江县| 镇康县| 闵行区| 尤溪县| 沙洋县| 富顺县| 洛隆县| 东城区| 灯塔市| 莱西市| 泊头市| 武宁县| 石狮市| 阿克苏市| 镇原县| 平江县| 五莲县| 红桥区| 诏安县| 宁陕县| 南平市| 济南市| 井冈山市| 永顺县| 集安市| 孙吴县| 伊金霍洛旗|