Shoutbox

Drag and Drop Menu Problem - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: Drag and Drop Menu Problem (/showthread.php?tid=55396)

Drag and Drop Menu Problem by michael_m91 on 01-30-2006 at 07:03 PM

In a webpage how can i give my useres choice like the google personalized homepage does.

Like in the picture seen, you can drag the items to the desired location.


[Image: attachment.php?pid=596965]


RE: Drag and Drop Menu Problem by Supersonicdarky on 01-30-2006 at 10:34 PM

u don't need activex, works fine in firefox


RE: Drag and Drop Menu Problem by Supersonicdarky on 01-30-2006 at 10:43 PM

how do you create with activex? ^o)


RE: Drag and Drop Menu Problem by michael_m91 on 01-30-2006 at 10:56 PM

I just wanna know howot make my own, like rafael_vansolini said


RE: Drag and Drop Menu Problem by RaceProUK on 01-31-2006 at 01:15 AM

quote:
Originally posted by rafael_vansolini
Probabily you need to use JavaScript and ActiveX controls.
JavaScript - yes. ActiveX - no. ActiveX is a highly insecure MS technology, and not supported by Firefox. You can, however, get the effectr you want using XHTML, JavaScript and CSS.
RE: Drag and Drop Menu Problem by ShawnZ on 01-31-2006 at 02:21 AM

quote:
Originally posted by michael_m91
I just wanna know howot make my own

With a lot of difficulty. Not worth the trouble.

RE: Drag and Drop Menu Problem by michael_m91 on 01-31-2006 at 03:04 AM

Is there a place i can get a template for somthin like this?

Or anybody know what its called so i can search it?


RE: Drag and Drop Menu Problem by ShawnZ on 01-31-2006 at 03:20 AM

Its not called anything...


RE: Drag and Drop Menu Problem by rav0 on 01-31-2006 at 07:14 AM

There isn't a simple way to do that.

That was built up (either by lots of people or in lots of time).

It would use very simple things built up together, like checking where the mouse is, placing an element in a new location the element, tracking mouse clicks yadayada.


RE: Drag and Drop Menu Problem by michael_m91 on 01-31-2006 at 10:25 PM

oh..... dammit lol i would have thought that somebody would know


RE: Drag and Drop Menu Problem by Supersonicdarky on 01-31-2006 at 10:26 PM

steal the code... if you can...


RE: Drag and Drop Menu Problem by michael_m91 on 02-01-2006 at 12:06 AM

lol yah im gonna try


RE: Drag and Drop Menu Problem by RaceProUK on 02-01-2006 at 12:24 AM

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.
RE: Drag and Drop Menu Problem by michael_m91 on 02-01-2006 at 12:45 AM

yah.. makes sence


RE: Drag and Drop Menu Problem by -dt- on 02-01-2006 at 01:49 AM

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.