TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 08-11-2009, 10:50 PM   #1 (permalink)
The Acquainted
 
buildakicker's Avatar
 
Join Date: Jan 2008
Posts: 119
Thanks: 21
buildakicker is on a distinguished road
Default Auto Animate Small Divs

Hi all,

I have been trying to figure out how to automatically animate a random number of divs on a page. All of the divs should just slowly float up to the top of the page... they could just float out of the screen and appear at the bottom floating up again.. whatever, that is beyond me right now...

So basically what I am thinking is...

Code:
Using Jquery Animate Function..

on page load begin to slowly move divs up page... like bubbles. 

when they reach the top they fade out and just reappear to the bottom and come to the top again in a loop...
Any thoughts on how to go about this?
__________________
SkiLeases.com
buildakicker is offline  
Reply With Quote
Old 08-11-2009, 11:02 PM   #2 (permalink)
The Acquainted
 
buildakicker's Avatar
 
Join Date: Jan 2008
Posts: 119
Thanks: 21
buildakicker is on a distinguished road
Default

Here's some Psudeocode
Code:
On page load
set all the divs on the bottom of the page
randomly begin to animate(float up the screen)
as they reach top, fade out and then begin at bottom of page again....
LOOP
__________________
SkiLeases.com
buildakicker is offline  
Reply With Quote
Old 08-12-2009, 12:20 AM   #3 (permalink)
The Addict
 
Join Date: May 2009
Posts: 287
Thanks: 5
adamdecaf is on a distinguished road
Default

Why not just loop in every div and move the CSS absolute position up a few pixels? It may[/will] look gagged but you could decrease the amount of divs.
__________________
My Site
adamdecaf is offline  
Reply With Quote
Old 08-12-2009, 10:16 AM   #4 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Have you looked into using one of the JS frameworks for their animation abstractions? jQuery for example would make something like this only a relatively few lines of code (well, depends on how you implement it).
Salathe is offline  
Reply With Quote
Old 08-12-2009, 05:17 PM   #5 (permalink)
The Acquainted
 
buildakicker's Avatar
 
Join Date: Jan 2008
Posts: 119
Thanks: 21
buildakicker is on a distinguished road
Default

Quote:
Originally Posted by Salathe View Post
Have you looked into using one of the JS frameworks for their animation abstractions? jQuery for example would make something like this only a relatively few lines of code (well, depends on how you implement it).
That's what I was thinking, something with JQuery. What I am struggling with is getting the animation to move through the page onload. I should do something like this right:

Code:
$(document).ready(function(){
   
function loopDiv(){
    $("#animatedDiv").show();
    $("#animatedDiv").animate({top:"100"},4000);
    $("#animatedDiv").fadeTo("slow",0);
  });

//don't know much about this yet...
jquery.each() //say I have 20 items, loop through the items, create div, animate.

});
__________________
SkiLeases.com
buildakicker is offline  
Reply With Quote
Old 08-13-2009, 08:20 PM   #6 (permalink)
The Acquainted
 
buildakicker's Avatar
 
Join Date: Jan 2008
Posts: 119
Thanks: 21
buildakicker is on a distinguished road
Default

Using a Timeout, I've got this working perty good with JQuery inside the function...

Code:
function addElement()
{
       var tx = 'Here you go!';
	var i=0;
	for(i=0; i<1; i++){
  		newDiv = document.createElement("div");
		newDiv.className = "num" + i;
		newDiv.id="animatedDiv";
	 	newDiv.innerHTML = "<div class='tweets'>"+ tx + "</div>";

  		// add the newly created element and it's content into the DOM
	  	my_div = document.getElementById("page");
  		document.body.insertBefore(newDiv, my_div);
	
		$(document).ready(function(){	
			$(".num0").fadeTo("slow",1);
			$(".num0").animate({top:"-140"},2000);
			$(".num0").fadeTo("slow",0);			
		}); 
  	}
	t=setTimeout("addElement()",1000);
}
__________________
SkiLeases.com
buildakicker is offline  
Reply With Quote
Reply



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

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
in css how to place divs hotizontally next to each other? sarmenhb XHTML, HTML, CSS 8 06-24-2008 03:43 AM
display:block pushes divs freenity XHTML, HTML, CSS 1 03-18-2008 09:13 PM
SQLite vs SimpleXML; For small redundant data stewart General 4 03-14-2008 10:10 PM


All times are GMT. The time now is 06:32 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design