Reply
Drag & drop & layers???
Old 10-27-2005, 07:37 PM Drag & drop & layers???
Average Talker

Posts: 22
Hello,

I am trying my hand at some javascript, specifically some drag & drop scripts. There is almost too much info. "out there"; I am being overwhelmed. My intent is to drag small images onto a larger image (furniture onto a floorplan). It appears that the furniture images are one layer and the floorplan is another. As I have it currently, when I drag the furniture onto the floorplan, the furniture actually gets behind the floorplan, rather than on top of it. If I may, here is the code I have thus far (a bit crude, I'll admit). Can someone please help me correct the code? Also, is there any way I can rotate each piece of furniture once it is dragged to the floorplan? Thank you!

<HTML>

<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<TITLE>dragdroptest</TITLE>

<LINK REL="stylesheet" TYPE="text/css" HREF="style.css">

<style type="text/css">
<!--
.dragme{position:relative;}
-->
</style>

<script type="text/javascript">

<!-- Begin
var ie=document.all;
var nn6=document.getElementById&&!document.all;
var isdrag=false;
var x,y;
var dobj;

function movemouse(e)
{
if (isdrag)
{
dobj.style.left = nn6 ? tx + e.clientX - x : tx + event.clientX - x;
dobj.style.top = nn6 ? ty + e.clientY - y : ty + event.clientY - y;
return false;
}
}

function selectmouse(e)
{
var fobj = nn6 ? e.target : event.srcElement;
var topelement = nn6 ? "HTML" : "BODY";
while (fobj.tagName != topelement && fobj.className != "dragme")
{
fobj = nn6 ? fobj.parentNode : fobj.parentElement;
}
if (fobj.className=="dragme")
{
isdrag = true;
dobj = fobj;
tx = parseInt(dobj.style.left+0,10);
ty = parseInt(dobj.style.top+0,10);
x = nn6 ? e.clientX : event.clientX;
y = nn6 ? e.clientY : event.clientY;
document.onmousemove=movemouse;
return false;
}
}
document.onmousedown=selectmouse;
document.onmouseup=new Function("isdrag=false");
// End -->
</script>
</head>
<body>
<div id="furniture">
<img src="http://www.lewisgardens.com/bed.gif" height="50" width="50" class="dragme"><br><br>
<img src="http://www.lewisgardens.com/bed2.gif" height="50" width="50" class="dragme">
</div>
<div id="floorplan">
<img src="floorplan.jpg" height="450" width="585">
</div>
</BODY>
</HTML>
kalew is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Reply     « Reply to Drag & drop & layers???
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.10860 seconds with 12 queries