drag doesn't work well ( too slow) -
12-04-2004
, 05:54 AM
Hi,
Clicking down and dragging the rabbit works without error but very slowly
and not smoothly, but i can't find my error in the code below:
(i use IE 6.0)
<BODY oncontextmenu="return false" scroll=no >
<IMG ID="rabbit"
STYLE="Position:absolute;left:200;top:150;width:10 0;height:150;z-index:1;
filter:blendtrans" SRC="bugs.gif" onMouseDown="downrabbit()"
onMouseUp="uprabbit()" width="100" height="149">
<script language=javascript>
var lap;
var sel;
var strid;
var x,y;
flag=0;
lap=document.getElementById("rabbit").style
function downrabbit()
{
lap.width=100
lap.height=149
strid=window.event.srcElement.id
if (strid=="rabbit")
sel=strid
}
function dragrabbit()
{
if (sel == "rabbit")
{
x=window.event.x
y=window.event.y
lap.left = x-50
lap.top = y-60
window.event.cancelBubble = true
window.event.returnValue = false
}
}
function uprabbit()
{
if (sel == "rabbit")
{
if (x<50)
lap.left=50
if (y<50)
lap.top=50
if (x>700)
lap.left=700
if (y>350)
lap.top=350
}
}
document.getElementById("rabbit").ondragstart=drag rabbit
</script>
</BODY>
thanks ben |