[Javascript] Moving elements with Javascript

Alan Easton alaneaston666 at hotmail.com
Tue Nov 27 03:51:18 CST 2007


Hello All,
 
Thanks for the advice.
 
I think I am nearly there, but have a slight problem which you may be able to help me with.
 
If you look at http://www.celweb.co.uk/js/slide.html
 
You will see it working to a degree.
 
But, what I have had to do is hack it a bit. Basically, I need to dynamically know the co-ordinates of 2 things:
 
- The icon next to the "Add to Basket" button.
- The top right basket image itself.
 
What I have done is just guess where on the page the "Add to Basket" icon is. This however, is impractical, as there will be text, images, etc on the page, generated from the DB and I just to not know how to put the icon next to the button, no matter where the button is??
 
Also, the top right basket image may not actually move, but I need its co-ordinates. I think the way I am getting the icon to the basket image is not the best, as it a hack based on where they are now on the page.
 
Please have a look at the page and code and see if you can come up with a better way of doing it.
 
Any help would be really appreciated.
 
Many Thanks,
 
Alan...


Date: Mon, 26 Nov 2007 21:49:38 -0700From: peter at brunone.comTo: javascript at lists.evolt.orgCC: Subject: Re: [Javascript] Moving elements with JavascriptSounds fairly simple; you could use absolute positioning to situate the elements (which is a bit of a pain to get right, but it's really the only way to get them moving).  Then you would adjust the style.left and style.top properties of the object, moving it incrementally using the Javascript setTimeout function, and when it reaches its destination, a simple style.display = "none" would make it disappear.That's the bones of it, anyway; at least you have some terms to research :)PeterFrom: "Rafael Menezes" soscpd at gmail.com
DHTML is the tool i recommend to this task.
 
Regards
Rafael 
On 26/11/2007, Alan Easton <alaneaston666 at hotmail.com> wrote: 

Hello everyone, I have a question about moving elements from one part of the screen to another. The situation is this. I am building a shopping cart, and would like to add a bit of fancy functionality. When a visitor clicks my "Add to Basket" icon, I would like the icon to then fly to a designated point on the screen, either to the top of the page, out of sight, or somewhere else on screen, then when it gets there, then to simply disappear.  I am not sure how hard this is, but I did see it on Microsoft's site, and thought it looked very cool. It is a cool feature to have, that's all, and I was wondering if any of you experts could help me out with it.  Any help as always is greatly appreciated. Many Thanks, Alan...
_________________________________________________________________
100’s of Music vouchers to be won with MSN Music
https://www.musicmashup.co.uk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20071127/416412cc/attachment.htm>


More information about the Javascript mailing list