> -----Original Message-----
> From: James Smith [mailto:[EMAIL PROTECTED]
> Sent: Friday, November 16, 2007 5:42 AM
> To: CF-Community
> Subject: Drag and Drop like iGoogle
> 
> I am looking for some way to allow our users to drag and drop some
> interface
> blocks around the screen but I have a few requirements I just don't
> seem to
> be able to meet.

This is the kind of thing I built my "PanelManager" for.  It doesn't do what
you want but rather abstracts all of the nitty-gritty so you can do what you
want.

http://www.depressedpress.com/Content/Development/JavaScript/Extensions/DP_P
anelManager/Index.cfm

There's a drag-and-drop example at the bottom of the page.

You can create a single panel manager to hold all your position-able
elements.  That will make it easier to deal with just those (you can loop
over the "panels" collection).  You can use the methods on your panels to
easily get the size, position, etc.  

In this case I would implement a basic drag and drop like this at first.
Just get that working with your blocks.

Next implement a collision detection script- just basic.  Loop over each
panel (ignoring the current one) and take the Position and then Size (giving
you the area).  You can do a simple "if my object's position is in this area
then I'm overlapping".

Next move the element however your rules dictate.  In this case you'd
probably just say "if you're on top of another element, move to just below
it".  Now run the collision detection again.  You could also do "insert" by
saying "if you're over an element move to where that element is.  Now move
the original element down to just below you".

You'd just keep running the collision detection over and over until nothing
was colliding - depending on your rules it might completely reformat the
page but the actual function would be quite small and simple.

In all these cases you'd probably just set the "left" position outright
(hardcoded horizontal positions).

The basic idea is just divide and conquer: all of the complex behavior can
be implemented as a series of simple rules.  The component just lets you
completely ignore all of the "background" work of getting and setting
information, browser compatibility, etc.

You've got me thinking about it now... I might try it just to see how simple
I could really make it.

Jim Davis


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Get the answers you are looking for on the ColdFusion Labs
Forum direct from active programmers and developers.
http://www.adobe.com/cfusion/webforums/forum/categories.cfm?forumid-72&catid=648

Archive: 
http://www.houseoffusion.com/groups/CF-Community/message.cfm/messageid:246538
Subscription: http://www.houseoffusion.com/groups/CF-Community/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.5

Reply via email to