function clipBoxMove(e) {
e.stopPropagation();
var mouseX = e.pageX;//鼠标横坐标
var mouseY= e.pageY;
var boxHeight=clipBox_div.offsetHeight;
var boxWidth=clipBox_div.offsetWidth;
var imgBoxHeight=imgBox_div.offsetHeight;
var imgBoxWidth=imgBox_div.offsetWidth;
var maxY=imgBoxHeight-boxHeight;
var maxX=imgBoxWidth-boxWidth;
var moveX=0;
var moveY=0;
if(isDraging==true)
{
moveX=mouseX-mouseOffsetX;
moveY=mouseY-mouseOffsetY;
moveX=Math.max(0,moveX);
moveY=Math.max(0,moveY);
moveX=Math.min(maxX,moveX);
moveY=Math.min(maxY,moveY);
clipBox_div.style.top=moveY+"px";
clipBox_div.style.left=moveX+"px";
}
}
4.实现实时预览区域
这个区域相对来说就好实现多了,直接来看看实现:
//截取显示区域
function setImgVisiable() {
var top=clipBox_div.offsetTop;
var left=clipBox_div.offsetLeft;
var bottom=top+clipBox_div.offsetHeight;
var right=left+clipBox_div.offsetWidth;
var imgTop=document.getElementById('imgTop');
imgTop.style.clip="rect("+top+"px,"+right+"px,"+bottom+"px,"+left+"px)";
}
//显示预览窗口
function setPreView() {
var top=clipBox_div.offsetTop;
var left=clipBox_div.offsetLeft;
var bottom=clipBox_div.offsetTop+clipBox_div.offsetHeight;
var right=clipBox_div.offsetLeft+clipBox_div.offsetWidth;
var imgView=document.getElementById('imgView');
imgView.style.clip="rect("+top+"px,"+right+"px,"+bottom+"px,"+left+"px)";
imgView.style.top= 100-top +"px";//我选了两个定点为基准点(680,100);
imgView.style.left=680-left +"px";
}
Admiring the dedication you put into your site and in depth information you offer. It’s good to come across a blog every once in a while that isn’t the same unwanted rehashed information. Fantastic read! I’ve bookmarked your site and I’m adding your RSS feeds to my Google account.
Admiring the dedication you put into your site and in depth information you offer. It’s good to come across a blog every once in a while that isn’t the same unwanted rehashed information. Fantastic read! I’ve bookmarked your site and I’m adding your RSS feeds to my Google account.
Thank you for your attention. I would appreciate it if you could share my website with your friends!