/**
* Created by Spades-k on 2016/8/17.
*/
define('h5/js/page/imageMagnification', [
'jquery'
],function($){
var dragBox=function(rddrag,selector,drag,right,bottom,close){
var oDiv=document.getElementById(rddrag);
var oDiv2=document.getElementById(selector);
var h2=document.getElementById(drag);
var right=document.getElementById(right);
var bottom=document.getElementById(bottom);
var sClose=document.getElementById(close);
var mouseStart={};
var divStart={};
var rightStart={};
var bottomStart={};
//往右拽
right.onmousedown=function(ev)
{
var oEvent=ev||event;
mouseStart.x=oEvent.clientX;
mouseStart.y=oEvent.clientY;
rightStart.x=right.offsetLeft;
if(right.setCapture)
{
right.onmousemove=doDrag1;
right.onmouseup=stopDrag1;
right.setCapture();
}
else
{
document.addEventListener("mousemove",doDrag1,true);
document.addEventListener("mouseup",stopDrag1,true);
}
};
function doDrag1(ev)
{
var oEvent=ev||event;
var l=oEvent.clientX-mouseStart.x+rightStart.x;
var w=l+oDiv.offsetWidth;
if(w<oDiv.offsetWidth)
{
w=oDiv.offsetWidth;
}
else if(w>document.documentElement.clientWi
完美拖拽+拖动改变Div的宽高+关闭按钮
最新推荐文章于 2024-06-26 10:30:02 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)