What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Drag and Drop Menu Problem

Pages: (2): « First « 1 [ 2 ] Last »
Drag and Drop Menu Problem
Author: Message:
Supersonicdarky
Veteran Member
*****

Avatar

Posts: 2317
Reputation: 48
– / – / Flag
Joined: Feb 2005
Status: Away
RE: Drag and Drop Menu Problem
steal the code... if you can...
01-31-2006 10:26 PM
Profile E-Mail PM Find Quote Report
michael_m91
Full Member
***


Posts: 371
Reputation: 1
33 / Male / –
Joined: Jan 2004
O.P. RE: Drag and Drop Menu Problem
lol yah im gonna try

[Image: Email.JPG]
02-01-2006 12:06 AM
Profile E-Mail PM Web Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: Drag and Drop Menu Problem
quote:
Originally posted by michael_m91
oh..... dammit lol i would have thought that somebody would know
It's quite a complex task, so no-one can remember everything about it.
[Image: spartaafk.png]
02-01-2006 12:24 AM
Profile PM Web Find Quote Report
michael_m91
Full Member
***


Posts: 371
Reputation: 1
33 / Male / –
Joined: Jan 2004
O.P. RE: Drag and Drop Menu Problem
yah.. makes sence

[Image: Email.JPG]
02-01-2006 12:45 AM
Profile E-Mail PM Web Find Quote Report
-dt-
Scripting Contest Winner
*****

Avatar
;o

Posts: 1819
Reputation: 74
36 / Male / Flag
Joined: Mar 2004
RE: Drag and Drop Menu Problem
wtf you are you people on about its not that complex :-/

your element looks like this
<div id="moveme" style="position:absolute;left:0px;top:0px;background:blue;width:90px;height:90px;"></div>

you get the reference to that div by going
code:
var element = document.getElementById('moveme');
you add an event listener for mousemove
code:
document.addEventListener('mousemove',test,false);

you have another event listener for mouse down and mouse up
code:
document.addEventListener('mouseup',testOff,false);
element.addEventListener('mousedown',testOn,false);

then you have three functions which control this , one to turn it on , one to turn it off and one to move the element.
code:

var ismoving = false
var dx = 0;
var dy = 0;

function testOn (e){
ismoving = true;
//now you have to get the orginal click point
dx= e.clientX - parseInt(element.style.left);
dy= e.clientY - parseInt(element.style.top);
}

function testOff(e){
if(ismoving){
//this helps to stop that slight jumping when you release a drag then drag it again.
dx= e.pageX - parseInt(element.style.top);
dy= e.pageY - parseInt(element.style.left);
}
ismoving = false;
}

function test(e){
if(ismoving){
//minus the current mouse position from the orginal location.
var left= e.clientX-dx;
var top = e.clientY-dy;

//now we move the element.
element.style.left = left + 'px';
element.style.top = top + 'px';
}
}




thats the basic idea behind the dragging.  then you would save the location in the testOff function and get a php script or something to move the element back there when the page loads.

This post was edited on 02-01-2006 at 01:49 AM by -dt-.
[Image: dt2.0v2.png]      Happy Birthday, WDZ
02-01-2006 01:49 AM
Profile PM Web Find Quote Report
Pages: (2): « First « 1 [ 2 ] Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On