ホームページ  >  記事  >  ウェブフロントエンド  >  jquery を使用して等倍の画像効果を実現する plug-in_jquery

jquery を使用して等倍の画像効果を実現する plug-in_jquery

WBOY
WBOYオリジナル
2016-05-16 18:22:311481ブラウズ
复制代码代码如下:

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 =
//自動放图片
var autoScaling = function() {
if (スケーリング) {
if (img.width > 0 && img.height > 0) {
if (img.width / img.height >= 幅 / 高さ) {
if (img.width > width) {
t.width(width);
t.height((img.height * width) / img.width);
}
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);
}
}
}
}
}
//处理ff下会自动读取缓存图片
if (img.complete) {
//alert("getToCache!");
autoScaling();
}
$("src", ""); $("加ダウンロード中t.after(loading); ;
$(img).load(function() {
autoScaling();
loading.remove();
t.attr("src", this.src);
t.show();
//alert("ついに!")
});
});
}

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。