图片拖拽

drag = 0;
move = 0;
//定义变量
var ie=document.all;
var nn6=document.getElementById&&!document.all;
var isdrag=false;
var y,x;
var oDragObj;
//移动函数
function moveMouse(e) {
 if (isdrag) {
 oDragObj.style.top  =  (nn6 ? nTY + e.clientY - y : nTY + event.clientY - y)+"px";
 oDragObj.style.left  =  (nn6 ? nTX + e.clientX - x : nTX + event.clientX - x)+"px";
 return false;
 }
}
//拖动函数
function initDrag(e) {
 var oDragHandle = nn6 ? e.target : event.srcElement;
 var topElement = "HTML";
 while (oDragHandle.tagName != topElement && oDragHandle.className != "dragAble") {
  oDragHandle = nn6 ? oDragHandle.parentNode : oDragHandle.parentElement;
 }
 if (oDragHandle.className=="dragAble") {
   isdrag = true;
   oDragObj = oDragHandle;
   nTY = parseInt(oDragObj.style.top+0);
   y = nn6 ? e.clientY : event.clientY;
   nTX = parseInt(oDragObj.style.left+0);
   x = nn6 ? e.clientX : event.clientX;
   document.onmousemove=moveMouse;
   return false;
 }
}
document.onmousedown=initDrag;
document.onmouseup=new Function("isdrag=false");

//滚轮滚动
function onWheelZoom(obj){
  zoom = parseFloat(obj.style.zoom);
  tZoom = zoom + (event.wheelDelta>0 ? 0.05 : -0.05);
  if(tZoom<0.1 ) return true;
  obj.style.zoom=tZoom;
  return false;
}
<div class="dragAble" id="block0" onMouseOver="dragObj=block0; drag=0;" style="z-index: 10;
        width: 500px;height:850px; position: absolute; top: 0px;border:1px solid #133651;box-sizing: border-box;-webkit-box-sizing: border-box;cursor: move;" onMouseOut=""
        drag="0">
<img onmousewheel="return onWheelZoom(this)" style="zoom: 0.4" src="" border="0" name="images1">
</div>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值