博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
jQuery拖动、滚轮查看大图-类似地图操作
阅读量:6899 次
发布时间:2019-06-27

本文共 1367 字,大约阅读时间需要 4 分钟。

源码提要:

。pageX,pageY 鼠标指针的位置,相对于文档的左边缘;

。parseInt(css("left"))的left值;
。mousedown、mouseup、mousemove 鼠标事件;
。DOMMouseScroll、onmousewheel 鼠标滚动事件;
源码:

$(function() { //鼠标拖动 var _move = false,_x, _y, $img = $("#pic"),w=$(".pic-area").width(),h=$(".pic-area").height(); $img.mousedown(function(e) { _move = true; _x = e.pageX - parseInt($(this).css("left"));//图片距左上角距离 _y = e.pageY - parseInt($(this).css("top")); return false; }); $img.mousemove(function(e) { if (_move) { var x = e.pageX - _x; var y = e.pageY - _y; if(x>0) x=0; if(x
0) y=0; if(y
0) x=0; $img.css({left:x}); }); $("#J-picview-top").click(function(){ var y= parseInt($img.css("top"))-20; if(y
0){ y=0; } $img.css({top:y}); }); //放大缩小 $("#J-picview-zoomIn").click(function(){ $img.width($img.width()*1.5); }); $("#J-picview-zoomOut").click(function(){ $img.width($img.width()*0.5); }); });

转载地址:http://dyvdl.baihongyu.com/

你可能感兴趣的文章
js闭包
查看>>
Xcode +SVN
查看>>
设置界面分析
查看>>
SQL中DateTime转换成Varchar样式
查看>>
java.util.AbstractList
查看>>
几个常见用于解决nginx负载均衡的session共享问题的办法
查看>>
setTimeOut、setInterval与clearInterval函数
查看>>
Appium原理及版本变化细节
查看>>
iphone ios 用xcode4.2开发 访问web service的功能
查看>>
Visual Studio 代码折叠快捷键(摘要)
查看>>
《2016ThoughtWorks技术雷达峰会----雷达新趋势》
查看>>
正则【备用】
查看>>
FeatureSelectors
查看>>
数据库防火墙DBShield安装
查看>>
sudo with no password
查看>>
Windows 局域网ping获取设备IP
查看>>
使用蓝图来扩展编辑器
查看>>
USACO题目——Transformations
查看>>
除了 UCAN 发布的鹿班和普惠体,这些设计工具也来自阿里
查看>>
转载----Python正则表达式指南
查看>>