Go Back  HTML Forums - Free Webmaster Forums and Help Forums > WEBSITE DEVELOPMENT > Client Side Scripting
User Name:
Password:
 

Reply
Thread Tools   Display Modes
  View First Unread
 
Old 10-15-2009, 04:34 PM
  #1
Sawtooth500
Lord (Level 16)
 
Sawtooth500's Avatar
 
Join Date: Nov 2007
Location: Chicago, IL. USA
Posts: 588
iTrader: (0)
Sawtooth500 is on a distinguished road
Javascript Animation?

Look at: http://test6.waltonstreetwebdesign.com/

So let's say I have a transparent PNG of a hot air balloon, and on page load I want this balloon to start at the bottom of the browser window and float up to the top, and then float out the top of the frame.

Can I do this with javascript? If so, how would I even go about it?
__________________
-Taras Hryniw

http://www.waltonstreetwebdesign.com
Sawtooth500 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-18-2009, 01:08 PM
  #2
uze
Aspirant (Level 2)
 
Join Date: Jul 2008
Posts: 14
iTrader: (0)
uze is on a distinguished road
I would say it's best to use a javascript library for this sort of thing.

I personally like jQuery (http://jquery.com/).

A javascript library has lots of functions you can use to easily achieve what you would normally find very difficult writing in javascript as a beginner.

The method (function) that is useful to you in this instance is 'animate', once you have installed jQuery (really easy to do BTW), you simply need to use something like this:

HTML
Code:
<img src="balloon.png" id="theBalloon" />
CSS
Code:
body {
position:relative;
}

#theBalloon {
position:absolute;
bottom:0;
left:0;
}
Javascript (jquery syntax)
Code:
$(function() {
	$("#theBalloon").animate( { top:"-1000px"}, 1000 );
}
This will move your image from the bottom (positioned by CSS) to the top then out of the browser viewport by 1000px (you could reduce this amount).

The second parameter of 1000 on the animate function call sets the speed, 1000 may be too fast so this can be easily adjusted.

I haven't tested this but I'm sure it's a good basis for you to experiment with & get the results you want.

All the best.

UzE.
uze is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote

Reply
KEEP TABS
SPONSORS
 
Boxedart



 
 


 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
  
 
 
 



 
  POSTING RULES
 
 
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 02:37 PM.

   

Mascot team created by Drawshop.com

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.