欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

圖片放大鏡jquery.jqzoom.js使用實(shí)例附放大鏡圖標(biāo)

 更新時(shí)間:2014年06月19日 15:23:35   投稿:whsnow  
這篇文章主要介紹了圖片放大鏡jquery.jqzoom.js的使用另附放大鏡圖標(biāo),需要的朋友可以參考下


1. jquery.jqzoom.js

//**************************************************************
// jQZoom allows you to realize a small magnifier window,close
// to the image or images on your web page easily.
//
// jqZoom version 2.2
// Author Doc. Ing. Renzi Marco(www.mind-projects.it)
// First Release on Dec 05 2007
// i'm looking for a job,pick me up!!!
// mail: renzi.mrc@gmail.com
//**************************************************************
(function ($) {
$.fn.jqueryzoom = function (options) {
var settings = {
xzoom: 200, //zoomed width default width
yzoom: 200, //zoomed div default width
offset: 10, //zoomed div default offset
position: "right",//zoomed div default position,offset position is to the right of the image
lens: 1, //zooming lens over the image,by default is 1;
preload: 1
};
if (options)
{
$.extend(settings, options);
}
var noalt = '';
$(this).hover(function () {
var imageLeft = $(this).offset().left;
var imageTop = $(this).offset().top;
var imageWidth = $(this).children('img').get(0).offsetWidth;
var imageHeight = $(this).children('img').get(0).offsetHeight;
noalt = $(this).children("img").attr("alt");
var bigimage = $(this).children("img").attr("jqimg");
$(this).children("img").attr("alt", '');
if ($("div.zoomdiv").get().length == 0)
{
$(this).after("<div class='zoomdiv'><img class='bigimg' src='" + bigimage + "'/></div>");
$(this).append("<div class='jqZoomPup'>&nbsp;</div>");
}
if (settings.position == "right")
{
if (imageLeft + imageWidth + settings.offset + settings.xzoom > screen.width)
{
leftpos = imageLeft - settings.offset - settings.xzoom;
} else
{
leftpos = imageLeft + imageWidth + settings.offset;
}
} else
{
leftpos = imageLeft - settings.xzoom - settings.offset;
if (leftpos < 0)
{
leftpos = imageLeft + imageWidth + settings.offset;
}
}
$("div.zoomdiv").css({ top: imageTop, left: leftpos });
$("div.zoomdiv").width(settings.xzoom);
$("div.zoomdiv").height(settings.yzoom);
$("div.zoomdiv").show();
if (!settings.lens)
{
$(this).css('cursor', 'crosshair');
}
$(document.body).mousemove(function (e) {
mouse = new MouseEvent(e);
/*$("div.jqZoomPup").hide();*/
var bigwidth = $(".bigimg").get(0).offsetWidth;
var bigheight = $(".bigimg").get(0).offsetHeight;
var scaley = 'x';
var scalex = 'y';
if (isNaN(scalex) | isNaN(scaley))
{
var scalex = (bigwidth / imageWidth);
var scaley = (bigheight / imageHeight);
$("div.jqZoomPup").width((settings.xzoom) / scalex);
$("div.jqZoomPup").height((settings.yzoom) / scaley);
if (settings.lens)
{
$("div.jqZoomPup").css('visibility', 'visible');
}
}
xpos = mouse.x - $("div.jqZoomPup").width() / 2 - imageLeft;
ypos = mouse.y - $("div.jqZoomPup").height() / 2 - imageTop;
if (settings.lens)
{
xpos = (mouse.x - $("div.jqZoomPup").width() / 2 < imageLeft) ? 0 : (mouse.x + $("div.jqZoomPup").width() / 2 > imageWidth + imageLeft) ? (imageWidth - $("div.jqZoomPup").width() - 2) : xpos;
ypos = (mouse.y - $("div.jqZoomPup").height() / 2 < imageTop) ? 0 : (mouse.y + $("div.jqZoomPup").height() / 2 > imageHeight + imageTop) ? (imageHeight - $("div.jqZoomPup").height() - 2) : ypos;
}
if (settings.lens)
{
$("div.jqZoomPup").css({ top: ypos, left: xpos });
}
scrolly = ypos;
$("div.zoomdiv").get(0).scrollTop = scrolly * scaley;
scrollx = xpos;
$("div.zoomdiv").get(0).scrollLeft = (scrollx) * scalex;
});
}, function () {
$(this).children("img").attr("alt", noalt);
$(document.body).unbind("mousemove");
if (settings.lens)
{
$("div.jqZoomPup").remove();
}
$("div.zoomdiv").remove();
});
count = 0;
if (settings.preload)
{
$('body').append("<div style='display:none;' class='jqPreload" + count + "'>sdsdssdsd</div>");
$(this).each(function () {
var imagetopreload = $(this).children("img").attr("jqimg");
var content = jQuery('div.jqPreload' + count + '').html();
jQuery('div.jqPreload' + count + '').html(content + '<img src=\"' + imagetopreload + '\">');
});
}
}
})(jQuery);
function MouseEvent(e) {
this.x = e.pageX;
this.y = e.pageY;
}

2. jqzoom.css

/*jQzoom*/
.jqzoom{
border:1px solid #BBB;
float:left;
position:relative;
padding:0px;
cursor:pointer;
}
div.zoomdiv {
z-index: 999;
position : absolute;
top:0px;
left:0px;
width : 200px;
height : 200px;
background: #ffffff;
border:1px solid #CCCCCC;
display:none;
text-align: center;
overflow: hidden;
}
div.jqZoomPup {
z-index : 999;
visibility : hidden;
position : absolute;
top:0px;
left:0px;
width : 50px;
height : 50px;
border: 1px solid #aaa;
background: #ffffff url(../images/zoomlens.gif) 50% top no-repeat;
opacity: 0.5;
-moz-opacity: 0.5;
-khtml-opacity: 0.5;
filter: alpha(Opacity=50);
}

3. html代碼

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title></title>
<script src="jquery-1.8.2.min.js" type="text/javascript"></script>
<script src="jquery.jqzoom.js" type="text/javascript"></script>
<link href="jqzoom.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
/*使用jqzoom*/
$(function() {
$(".jqzoom").jqueryzoom({
xzoom: 400, //放大圖的寬度(默認(rèn)是 200)
yzoom: 400, //放大圖的高度(默認(rèn)是 200)
offset: 10, //離原圖的距離(默認(rèn)是 10)
position: "right", //放大圖的定位(默認(rèn)是 "right")
preload: 1
});
});
</script>
</head>
<body>
<div class="jqzoom">
<img src="images/shoe1_small.jpg" style="width:300px; height:300px;" alt="" jqimg="images/shoe1_big.jpg" id="bigImg"/>
</div>
</body>
</html>

附件:放大鏡圖標(biāo)(zoomlens.gif)

相關(guān)文章

  • jQuery的學(xué)習(xí)步驟

    jQuery的學(xué)習(xí)步驟

    首先我建議大家去看看<JQUERY實(shí)戰(zhàn)>這本書,稍后我會(huì)提供本書的jquery實(shí)戰(zhàn)PDF版本。能省點(diǎn)銀子最好啊。
    2011-02-02
  • jquery復(fù)選框多選賦值給文本框的方法

    jquery復(fù)選框多選賦值給文本框的方法

    這篇文章主要介紹了jquery復(fù)選框多選賦值給文本框的方法,涉及jQuery相關(guān)選擇器的使用技巧,需要的朋友可以參考下
    2015-01-01
  • 使用jQuery實(shí)現(xiàn)簡單穿梭框方式

    使用jQuery實(shí)現(xiàn)簡單穿梭框方式

    這篇文章主要介紹了使用jQuery實(shí)現(xiàn)簡單穿梭框方式,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-10-10
  • JQuery篩選器全系列介紹

    JQuery篩選器全系列介紹

    jQuery提供了強(qiáng)大的選擇器讓我們獲取對象。在這邊,我人為地將jQuery選擇器分為兩大部分:選擇對象和篩選條件。選擇對象表示要獲取什么對象,篩選條件是對獲取的對象進(jìn)行篩選,最終留下符合某些特征的對象
    2013-08-08
  • jQuery插件zTree實(shí)現(xiàn)獲取當(dāng)前選中節(jié)點(diǎn)在同級(jí)節(jié)點(diǎn)中序號(hào)的方法

    jQuery插件zTree實(shí)現(xiàn)獲取當(dāng)前選中節(jié)點(diǎn)在同級(jí)節(jié)點(diǎn)中序號(hào)的方法

    這篇文章主要介紹了jQuery插件zTree實(shí)現(xiàn)獲取當(dāng)前選中節(jié)點(diǎn)在同級(jí)節(jié)點(diǎn)中序號(hào)的方法,結(jié)合實(shí)例形式分析了屬性插件zTree針對節(jié)點(diǎn)序號(hào)的相關(guān)操作技巧,需要的朋友可以參考下
    2017-03-03
  • Jquery解析Json格式數(shù)據(jù)過程代碼

    Jquery解析Json格式數(shù)據(jù)過程代碼

    Json是一種輕量級(jí)的數(shù)據(jù)交換格式,本節(jié)為大家介紹的是Jquery解析Json格式數(shù)據(jù)的過程,很詳細(xì),看看就知道了
    2014-10-10
  • 利用jquery操作Radio方法小結(jié)

    利用jquery操作Radio方法小結(jié)

    用Radio來實(shí)現(xiàn)用戶的選擇效果,在項(xiàng)目中積累了一些利用JQUERY來操作Radio的方法,這里與大家分享下
    2014-10-10
  • 關(guān)于html+ashx開發(fā)中幾個(gè)問題的解決方法

    關(guān)于html+ashx開發(fā)中幾個(gè)問題的解決方法

    在跟html+ashx打交道的園友們肯定會(huì)發(fā)現(xiàn),這種模式雖然優(yōu)美,但在開發(fā)中會(huì)遇到一些難處理的地方。我也不例外,下面是自己在實(shí)際開發(fā)中總結(jié)出來的幾條經(jīng)驗(yàn),希望跟大家分享,更希望得到大家的建議和更好的解決方法!
    2011-07-07
  • jQuery實(shí)現(xiàn)可兼容IE6的滾動(dòng)監(jiān)聽功能

    jQuery實(shí)現(xiàn)可兼容IE6的滾動(dòng)監(jiān)聽功能

    這篇文章主要介紹了jQuery實(shí)現(xiàn)可兼容IE6的滾動(dòng)監(jiān)聽功能,結(jié)合實(shí)例形式分析了jQuery針對不同瀏覽器的事件監(jiān)聽、響應(yīng)及頁面屬性動(dòng)態(tài)變換相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下
    2017-09-09
  • 淺談ajax請求不同頁面的微信JSSDK問題

    淺談ajax請求不同頁面的微信JSSDK問題

    下面小編就為大家分享一篇淺談ajax請求不同頁面的微信JSSDK問題,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-02-02

最新評論