• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

"floating DIVS"

 
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, I've seen some example code on this, and it seems rather crazy.

I don't understand why they make it so hard..

All you need to do is get the current top and left coordinates of the div right?(on mouseevent ofcourse) and then as the user "drags" the div change the top and left to the new ones as they drag.

I know about the javascript mousedown/up/click events, but where would I go to get an "api" on that kind of stuff.

even if your div is at first "position:static" you can just change it to absolute when the drag.

and then you could change up the position easily once you are able to get the coordinates.

Thanks,

Justin Fox
[ January 27, 2008: Message edited by: Bear Bibeault ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"floating divs" is ambiguous, but from your text I assume you're talking about drag-and-drop.

There are a lot of nuances to it -- why are you trying to implement this yourself when so many implementations already exist (Scriptaculous and jQuery UI, for example)?
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a div I made that has a products images and descriptions, you can click on the thumbnails and go through the different angles of the product, and it looks like a "window".

But I want the user to be able to drag it around.

Besides, I rather do it myself, it would not only be really cool looking, but it would be self gratifying also.

Justin Fox
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I only need a nudge in the right direction, I believe I could figure it out. I just need to know where to look to find out what I need to use to get this working.

Justin Fox
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Essentially you need to capture mouse click and move events and adjust the positioning of the element accordingly. Be aware the such event handling is highly browser-dependent if you want it to work in more than one browser.

Personally, I prefer the jQuery way:
[ January 26, 2008: Message edited by: Bear Bibeault ]
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not too familiar with JQuery. Is that basically JSP stuff? If so, the company I work for doesn't have a JSP engine on their server.

Justin Fox
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JQuery has nothing to do with JSP.

http://jquery.com/

and their api for draggable

http://docs.jquery.com/UI/Draggables


Eric
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like Eric said, jQuery is a JavaScript library (were you not around last week during the promotion?). Not sure where you got some sort of JSP connection.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic