BetaArchive Logo
Navigation Home Screenshots Image Uploader Server Info FTP Servers Wiki Forum RSS Feed Rules Please Donate
UP: 1d, 3h, 14m | CPU: 7% | MEM: 4223MB of 10219MB used
{The community for beta collectors}

Forum rules


Any off topic discussions should go in this forum. Post count is not increased by posting here.
FTP Access status is required to post in this forum. Find out how to get it


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 PostPost subject: Div following another div        Posted: Thu May 29, 2008 5:40 pm 
Reply with quote
Donator
User avatar
Offline

Joined
Thu Aug 31, 2006 2:45 pm

Posts
1432

Location
UK

Favourite OS
Longhorn 4074
I'm experimenting a little with Java Scripts and divs and i've found nice script that lets me drag and drop div with mouse. What i want to do is another div that will be not draged with mouse but when a dragable div will be draged, this div will be draged too. How can i do it?


Top  Profile  WWW
 PostPost subject:        Posted: Thu May 29, 2008 7:20 pm 
Reply with quote
Donator
Offline

Joined
Tue Oct 17, 2006 8:26 pm

Posts
930
A div in a div is still part of the parent div. If you move the parent and all of its contents, then the child div should move as well.

Can't say much more without seeing some code.


Top  Profile
 PostPost subject:        Posted: Thu May 29, 2008 7:49 pm 
Reply with quote
Donator
User avatar
Offline

Joined
Thu Aug 31, 2006 2:45 pm

Posts
1432

Location
UK

Favourite OS
Longhorn 4074
If i will set the moving layer to the parent div i will be able to move the layers by draging all layers so i can't do it.

Here's the script i got:
Code:
<SCRIPT TYPE="text/javascript">
cpdd='**********   DRAG & DROP   *********?=   '+
'Written by Bogdan Blaszczak                   '+
'homepage http://www.blatek.25.pl/javascript/'
//don't edit lines above

var selOB,glIx=0
function DragObj(w){
with(d)this.id=g?g(w):a?a[w]:d.l[w]
if(d.l)this.id.captureEvents(Event.MOUSEDOWN)
this.id.onmousedown=C
this.id.onselectstart=new Function('return false')
 function C(e){
 eval(st(hots,cpdd))
 selOB.zIndex=++glIx
 e=e||event
 selOB.X=e.pageX?e.pageX-(d.l?this.left:this.offsetLeft):event.offsetX
 selOB.Y=e.pageY?e.pageY-(d.l?this.top:this.offsetTop):event.offsetY
 if(!d.l)return false//Mac?
 }
}
function Drop(){selOB=null}
function Drag(e){
e=e||event
if(selOB)with(selOB){
 left=(e.pageX?e.pageX:event.clientX+d.body.scrollLeft)-X
 top=(e.pageY?e.pageY:event.clientY+d.body.scrollTop)-Y}
return false;
}
hots=[124,90,118,22,59,37,55,116,118,36,110,96,43,124,100,110,96,127,124,113,62,97,50,118,94]
function st(t,h){var s='';for(var i=0;i<t.length;i++)s+=h.substr(t[i],1);return s}
function NSres(f){
if(f==true){document.dW=innerWidth;document.dH=innerHeight;onresize=NSres}
else if(innerWidth!=document.dW||innerHeight!=document.dH)location.reload()
}if(document.layers)NSres(true);

function initDrag(){
d=document,d.l=d.layers,d.a=d.all,d.g=d.getElementById
//zdefiniuj warstwy, kt√≥re mają być przeciągane
new DragObj('window_title')
if(d.l)d.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP)
d.onmousemove=Drag
d.onmouseup=Drop
}
</SCRIPT>

and here is the body:
Code:
<body onload="initDrag()">
<div id="window">
   <div id="window_title">
   title
   </div>
   <div id="window_content">
   content...
   </div>
</div>
</body>

so i want the window_content to get moved when moving window_title but i don't want to be able to move window_content itself...


Top  Profile  WWW
 PostPost subject:        Posted: Sun Oct 05, 2008 3:30 pm 
Reply with quote
FTP Access
User avatar
Offline

Joined
Sun Oct 05, 2008 3:11 pm

Posts
105
i guess you have to move the parent object of window_title / selOB : selOB.parentNode


Top  Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 




Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  

All views expressed in these forums are those of the author and do not necessarily represent the views of the BetaArchive site owner.

Powered by phpBB® Forum Software © phpBB Group

Copyright © 2006-2018

 

Sitemap | XML | RSS