Solved

Jquery multiple animations

Posted on 2013-01-17
2
414 Views
Last Modified: 2013-01-17
I have some basic knowledge in jQuery, I do some stuff, and I construct a basic animation and I want develop more.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Untitled Document</title>
<script src="../../ficheiros_apoio/jquery.min.js"></script>
<style type="text/css">
#geral{position: absolute; width: 600px; height: 600px;}
#piece{position: absolute; width: 13px; height: 20px; left: 20px; top: 150px;}
</style>
</head> 
<body> 
<div id="geral">
<div id="piece"><img src="ponteiro_rato.png" alt="Rato" width="13" height="20" /></div>
</div>
<script>
$('#piece').animate({
left: '500',
top: '500',
}, 2500, function() {
alert("working");
});
</script>
</body> 
</html>

Open in new window

The code in snippet code shows a basic animation that just moves the "div piece" to other place. And I opened this question because I want do two things more in my animation:
After complete my initial move, I need in animation pause 5 seconds, and after the pause, the "div piece" moves to this coordinates "left: 150px and top: 100px".
Can you show me how I do that?

The best regards, JC
0
Comment
Question by:Pedro Chagas
2 Comments
 
LVL 38

Assisted Solution

by:Tom Beck
Tom Beck earned 260 total points
ID: 38789301
$('#piece').animate({
	left: '500px',
	top: '500px',
}, 2500, function() {
	var t = setTimeout( function() {
		$('#piece').animate({
			left: '150px',
			top: '100px'
		});
	},5000)
});

Open in new window

0
 
LVL 82

Accepted Solution

by:
leakim971 earned 240 total points
ID: 38789389
another one : http://jsfiddle.net/kGrQ3/
$('#piece').animate({ left: '500', top: '500', }, 2500).delay(5000).animate({ left: '150', top: '100', }, 2500);

Open in new window

0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question