jqury.jqzoom插件--放大镜
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style>
/*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: #ccc;
opacity: 0.5;
-moz-opacity: 0.5;
-khtml-opacity: 0.5;
filter: alpha(Opacity=50);
}
</style>
</head>
<body>
<div class="jqzoom">
<img src="2.jpg" alt="" jqimg="1.jpg"/>
</div>
</body>
<script src="jquery-1.11.3.min.js" type="text/javascript"></script>
<script src="jquery.jqzoom.js" type="text/javascript"></script>
<script>
$(function() {
$(".jqzoom").jqueryzoom({
xzoom: 300, //放大图的宽度(默认是 200)
yzoom: 300, //放大图的高度(默认是 200)
offset: 10, //离原图的距离(默认是 10)
position: "right", //放大图的定位(默认是 "right")
preload: 1
});
});
</script>
</html>
html
//**************************************************************
// 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'> </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;
}
jquery.jqzoom.js
class名是jqzoom的div中,img的src属性中放的是小图的路径,jqimg属性中放的是对应大图的路径
jqury.jqzoom插件--放大镜的更多相关文章
- jquery中用jqzoom实现放大镜效果
使用的jqzoom 插件实现的放大镜的效果 jqzoom 里面的代码 : 直接copy就好 //**************************************************** ...
- jqzoom插件图片放大功能的一些BUG
建议使用cloud-zoom插件,jqzoom插件就不要使用了 点击查看——图片放大镜——jQuery插件Cloud Zoom 刚开始使用的是jqzoom插件,但问题太多了,就不说插入到页面中使用了, ...
- js插件---放大镜如何使用
js插件---放大镜如何使用 一.总结 一句话总结:一张高清图片被用了两次,一次做缩略图,一次做放大后显示用的的图片(其实这个图片就是高清图片本身,而且是部分) 14 <figure class ...
- Jquery的jqzoom插件的使用(图片放大镜)
今天学习一下,图片放大镜功能,需要使用插件JQzoom 引入文件 <script type="text/javascript" src="js/jquery.min ...
- jqzoom图片放大镜
jqzoom是一个图片放大器插件.它功能强大,使用简便! 引入js与css: <script type="text/javascript" src="js/jque ...
- jqzoom插件
<!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title> ...
- jquery jqzoom插件练习
<!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> ...
- 使用jqzoom插件时
[javascript] view plaincopy /*使用jqzoom*/ $(function() { $(".jqzoom").jqueryzoom({ xzoom: 3 ...
- jquery.jqzoom.js图片放大镜
jqzoom插件实现图片放大镜效果 1. jquery.jqzoom.js //************************************************************ ...
随机推荐
- 高通平台 lcd driver 调试小结
一.概述 1.1 简介 本文档主要包括LCD模块的驱动流程分析.Framebuffer相关知识.Gralloc等相关内容,以及LCD调试的一些经验和相关bug的分析和讲解. 1.2 开发环境 And ...
- 四HttpServletResponse常见应用——生成验证码
转载自http://www.cnblogs.com/xdp-gacl/p/3791993.html 一.HttpServletResponse常见应用——生成验证码 1.1.生成随机图片用作验证码 生 ...
- CocoaPods的安装[转载]
[转载] 原地址http://www.tuicool.com/articles/7VvuAr3 觉得很好,很有用 iOS 最新版 CocoaPods 的安装流程 1.移除现有Ruby默认源 $gem ...
- 并行parallel和并发concurrent的区别
http://stackoverflow.com/questions/1050222/concurrency-vs-parallelism-what-is-the-difference Concurr ...
- CentOS7编译安装Nginx-1.8.1和编译参数
CentOS7编译安装Nginx-1.8.1和编译参数 Web服务器Nginx LNMP是一组众所周知的Web网站服务器架构环境,即由Linux+Nginx+MySQL+PHP(MySQL有时也 ...
- POJ 1142 Smith Numbers(史密斯数)
Description 题目描述 While skimming his phone directory in 1982, Albert Wilansky, a mathematician of Leh ...
- 用wordpress制作网站的总结
在没有自己的网站的时候很像拥有一个属于自己的网站,可以说是自己的一个愿望吧.但是当我真正的运行起来了之后觉得没有多么的兴奋,自己也折腾了几天wordpress,从买域名空间,到安装WP,遇到了一些问题 ...
- SQL查询语句 group by后, 字符串合并
合并列值 --******************************************************************************************* 表 ...
- TCP三次握手及四次挥手详细 转
一.TCP报文格式 TCP/IP协议的详细信息参看<TCP/IP协议详解>三卷本.下面是TCP报文格式图: 图1 TCP报文格式 上图中有几个字段需要重点介绍下: ...
- 使用Select命令创建菜单
创建文本菜单的一半功夫都花在了创建菜单布局和获取输入的字符上.bash shell提供了一个很容易上手的小工具来自动完成这些工作select命令允许从单个命令行创建菜单,然后在提取输入的答案并自动处理 ...