jqzoom插件

<!DOCTYPE html>
<html>
<head>
 <meta charset="utf-8"/>
 <title></title>
 <style type="text/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(zoomlens.gif) 50% top no-repeat;
   opacity: 0.5;
   -moz-opacity: 0.5;
   -khtml-opacity: 0.5;
   filter: alpha(Opacity=50);
  }
 </style>
</head>
<body>

<div class="jqzoom">
 <img src="j_small.jpg" style="width:300px; height:300px;" jqimg="j_big.jpg" id="bigImg"/>
</div>

<script type="text/javascript" src="../js/jquery-1.11.0.js"></script>
<script type="text/javascript">
 //**************************************************************
 // 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: [email protected]
 //**************************************************************
 (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 + ‘\">‘);
    });
   }
  }
 })($);
 function MouseEvent(e) {
  this.x = e.pageX;
  this.y = e.pageY;
 }
</script>
<script type="text/javascript">
 /*使用jqzoom*/
 $(function () {
  $(".jqzoom").jqueryzoom({
   xzoom: 200, //放大图的宽度(默认是 200)
   yzoom: 200, //放大图的高度(默认是 200)
   offset: 10, //离原图的距离(默认是 10)
   position: "right", //放大图的定位(默认是 "right")
   preload: 1
  });
 });
</script>
</body>
</html>
时间: 2024-08-05 04:15:39

jqzoom插件的相关文章

jquery jqzoom插件练习

<!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title></title> <script src="../Packages/jQuery.1.8.3/jquery-1.8.3.min.js"

jqzoom 插件 用例

一.效果图 jqzoom插件用于产生图片放大镜效果,效果图如下: 二.引入 1.引入 jQuery <script src="本地目录或cdn地址/jquery.js" type="text/javascript"></script> 2.引入 jqzoom插件 <script src="路径/jquery.jqzoom.js" type="text/javascript"></scr

jqzoom插件图片放大功能的一些BUG

建议使用cloud-zoom插件,jqzoom插件就不要使用了 点击查看——图片放大镜——jQuery插件Cloud Zoom 刚开始使用的是jqzoom插件,但问题太多了,就不说插入到页面中使用了,就单单插件本身带的实例 Bug1:先天性营养不良 你就不能使用margin:0 auto;把它放到一个居中显示的模块.也只能靠窗口最左边显示,要不就是用margin-left让它靠左边一定距离显示,但你要想让它想一般的网站里能适应不同宽度的浏览器,怕是不好用了. Bug2:后天发育不足 jqzoom

Jquery的jqzoom插件的使用(图片放大镜)

今天学习一下,图片放大镜功能,需要使用插件JQzoom 引入文件 <script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="js/jquery.jqzoom.js"></script> <!--<link rel="s

jquery.jqzoom.js图片放大镜

jqzoom插件实现图片放大镜效果 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 // Autho

16个非常酷的jQuery插件

摘要: 下面所有的插件有很大的功能,我相信大多数会帮助你即将到来的项目.借助他们可以使你的网站更加绚丽多彩. Lens Flare in JavaScript 这个jQuery插件可以帮助你处理图片,比如你可以在图片上添加一束光.下面这个图,可以控制太阳绕着地球旋转 How to Create Ajax Search Using PHP jQuery and MYSQL 这是一个基于Ajax的搜索框. Awesome Cufonized Fly-out Menu with jQuery and

jquery插件cloud-zoom(放大镜)

效果预览:http://www.helloweba.com/demo/cloud-zoom/ 源代码下载:http://pan.baidu.com/s/1eQnadXo Cloud Zoom是一个图像放大jQuery插件,效果堪比Magic Zoom.相对于流行jQZoom插件,Cloud Zoom体积小,有更多的功能和更强大的跨浏览器兼容性. 查看演示 特点 兼容大多数浏览器,(已经测试通过的浏览器有:IE6+, Firefox, Chrome, Opera, Safari) 易于集成的基本有

15款商城网站常用的图片放大镜特效

jquery图片放大镜效果制作变焦镜头图片放大查看代码 jQuery图片放大镜插件鼠标悬停图片放大镜头显示代码 jQuery鼠标滑过图片放大镜效果_淘宝图片放大镜代码 jquery jqzoom仿京东商城商品详细页面图片放大镜_选项卡切换效果 原生js MagicZoom.js放大镜插件商城商品多图片放大镜效果展示 jquery.imagezoom图片放大镜插件仿淘宝店铺商品放大镜展示 jquery etalage图片放大镜插件鼠标移到小图片放大预览图片 jQuery图片放大窗口显示和图片组合缩

Web静态开发 JQuery

伍章 JQuery 1节介绍JQuery和顶级对象 <<锋利的JQuery>>JQuery官网: http://jquery.com (下载jquery工具)JQuery在线API: http://api.jquery.com http://api.jquery.com/api(xml文件)JQuery UI: http://jqueryui.com 什么是JavaScript框架库?普通javascript的缺点:每种控件的操作方式不统一,不同浏览器下有区别,要编写跨浏览器的程序