日期:2014-05-16  浏览次数:20409 次

快速拖动层引发的断离现象?
一个层,鼠标按住后可以在页面上拖动,但是如果拖动速度过快,鼠标就会移出层区域,拖动终止?

怎么预防这样的现象?

1.鼠标可以移出层,但是有某个缓冲容器能记录鼠标路径,随后层会继续移动到鼠标位

2.用某个方式让鼠标无法快速移出层的区域

3.层拖动的定位方式重写

哪个是比较合适的解决方法?

ps   :   4.无解

==============================================================


<%@   page   language= "java "   import= "java.util.* "   pageEncoding= "UTF-8 "%>
<%
String   path   =   request.getContextPath();
String   basePath   =   request.getScheme()+ ":// "+request.getServerName()+ ": "+request.getServerPort()+path+ "/ ";
%>

<!DOCTYPE   HTML   PUBLIC   "-//W3C//DTD   HTML   4.01   Transitional//EN ">
<html>
<base   href= " <%=basePath%> ">
    <head>
        <title> My   JSP   'test.jsp '   starting   page </title>
<script   type= "text/javascript ">
var   mX;
var   mY;
var   flag=0;
function   get_x(){
mX=event.x;
mY=event.y;
}
function   mousedown()
{
mX=event.x;
mY=event.y;
flag=1;
}
function   mouseup()
{
flag=0;
}
function   mousemove()
{
if(flag==0)return   false;
var   e=document.getElementById( 'aa ');
mXmov=event.clientX;
mYmov=event.clientY;
var   w=e.offsetWidth;
e.style.width=parseInt(w)+parseInt(mXmov-mX);
}
</script>
<style   type= "text/css ">
div{float:left;}
.aaCss{border:1px   solid   red;width:200px;height:100px;}
</style>
    </head>
   
    <body   onmousemove= "get_x() ">
        <div   id= "body "   onmouseup= "mouseup() ">
        <div   id= "aa "   class= "aaCss "> AAAA </div>
        <div   onmousedown= "mousedown() "   onmousemove= "mousemove() "   id= "bb "   style= "width:30px;border:1px   solid   gary; "> dragMe </div>
        </div>
    </body>
</html>


------解决方案--------------------
点击后在body之类的元素注册移动事件
------解决方案--------------------
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<title> </title>
<script language= "javascript ">
var ie = navigator.appName == "Microsoft Internet Explorer ";
var count = 24;
var r = 80; //圆半径
var speed = 8; //速度

var arc = 0;
var newLeft = oldLeft = 0;
var newTop = oldTop = 0;
var divs = [];

function init()
{
for(var i=1;i <=count;i++)
{
var div = document.createElement( "DIV ");
with(div.style)
{
width = 2;
height = 2;
backgroundColor = "#FF0000 ";
position = "absolute ";
zIndex = i + 10;
}
div.id = "div " + i;
div.innerHTML = "