Closed Thread Icon

Topic awaiting preservation: Help Getting started moving DIV elements (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=22638" title="Pages that link to Topic awaiting preservation: Help Getting started moving DIV elements (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Help Getting started moving DIV elements <span class="small">(Page 1 of 1)</span>\

 
Karl
Bipolar (III) Inmate

From: Phoenix
Insane since: Jul 2001

posted posted 07-20-2004 16:39

Hello,

I've been searching for code to do the following:

On MouseOver of DIV element, Highlight the element (fill background color), then if user click on (within) this div element, move the DIV element with the cursor.

That seems easy, just not sure how to get started.

Karl

BillyRayPreachersSon
Nervous Wreck (II) Inmate

From: London
Insane since: Jul 2004

posted posted 07-20-2004 16:59

Take a look at this "crosshair" script:

http://dynamicdrive.com/dynamicindex13/crosshair.htm

Given that the mouse following routines are fairly cross-browser, that would be a good script to modify. I'm sure that getting a single DIV to follow the cursor (instead of 2 DIVs) would be a doddle... And making it so it only followed after a click would be a simple matter of toggling a "followState" (or whatever you want to call it) variable.

Hope this helps,
Dan

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 07-20-2004 17:22

hm... that doesn't work in opera 7.5x.

InI
Maniac (V) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 07-20-2004 17:31

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

BillyRayPreachersSon
Nervous Wreck (II) Inmate

From: London
Insane since: Jul 2004

posted posted 07-20-2004 18:05
quote:
But don't copy paste shitty snippets from dynamicdrive



I don't see anything wrong with using the DD code as a starting point to build on/modify. I suggested it purely because of its cross-browser event handling, not because of the tidiness of the code ;o)

Dan

InI
Maniac (V) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 07-20-2004 18:11

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

BillyRayPreachersSon
Nervous Wreck (II) Inmate

From: London
Insane since: Jul 2004

posted posted 07-20-2004 18:24

I like the beyondwonderland site - it's just a shame at 800x600 that you cannot view all of the text on any of the pages (no scrollbars are present on any page).

Dan

InI
Maniac (V) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 07-20-2004 18:31

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Karl
Bipolar (III) Inmate

From: Phoenix
Insane since: Jul 2001

posted posted 07-20-2004 18:31

I need to know which DIV element I am hovering over...
Would like to create a single mouse click event for all DIVS and pass the *active* div to this event. Possibly, the event simply references a global object when the event is fired...

Karl

BillyRayPreachersSon
Nervous Wreck (II) Inmate

From: London
Insane since: Jul 2004

posted posted 07-20-2004 18:38
quote:
I need to know which DIV element I am hovering over...



You could keep track of this in a global variable, which gets set whenever the onmouseover event on a DIV fires.

If you don't fancy putting an "onmouseover" event on every DIV in code, you could either do it programatically (after page has loaded), or use behaviours (assuming you're OK with IE only).

Dan

Karl
Bipolar (III) Inmate

From: Phoenix
Insane since: Jul 2001

posted posted 07-20-2004 18:53

Not a problem including "mouseover" event for each DIV.. I am building the pages using XSLT, so one update.

Hmmm... couldn't I just have a mouseclick event? Duhh, wouldn't I know which DIV fired off this event? Then all mousedown events could call a single DO_MY_MOVE_ROUTINE which would move the DIV.

I would still need to know which DIV element I am floating over while dragging -- I am going to create a SWAP_DIV routine, which basically swap "shift-down" existing DIV tags where the DIV being dragged is dropped.
These shifts will be restricted verticaly only shifts. So if I drag DIV "C" up and to the location of DIV "A", the new arrangment should be:

DIV "C"
DIV "A"
DIV "B"

[edit: woops fixed that order!]

Karl

(Edited by Karl on 07-20-2004 18:54)

InI
Maniac (V) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 07-20-2004 19:03

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

InI
Maniac (V) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 07-20-2004 19:09

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

BillyRayPreachersSon
Nervous Wreck (II) Inmate

From: London
Insane since: Jul 2004

posted posted 07-20-2004 23:36

For some example code of dragging DIVs around, check out my (non dynamic drive ) Tek-Tips FAQ here:

http://www.tek-tips.com/faqs.cfm?spid=216&sfid=5190

Unfortunately, it's IE only ATM, until I get around to updating it

Dan

Rinswind 2th
Maniac (V) Inmate

From: Den Haag: The Royal Residence
Insane since: Jul 2000

posted posted 07-21-2004 00:41

This link might interest you:
http://cross-browser.com/x/examples/drag1.php
they seem to use an Javascript library(shrudders) but at least the divs could be dragged aroud in
firefox 0.8, MSIE 6 and opera. I am not very comfortable with javascript but this contain some usefull info.
Also take a look to this:
http://www.sitepoint.com/forums/showthread.php?t=179557

good luck

------------------------------
Support Justice for Pat Richard

(Edited by Rinswind 2th on 07-21-2004 00:47)

« BackwardsOnwards »

Show Forum Drop Down Menu