I am building a site that uses multiple css animations that "chain" following a single button press and I'm having trouble with the required jQuery (I'm not very experienced with it).
The following is a simple site that I've built to get the code right- it consist of two identical balls - one fades out and the other moves left to right.
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<link href="css/move.css" rel="stylesheet" type="text/css">
<script src="http://code.jquery.com/jquery-2.0.1.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
</head>
<body>
<section class="container">
<figure id="ball"></figure>
<figure id="ball2" </figure>
</section>
<section class="controls">
<button class="button" id="button">Forwards</button>
</section>
<script type="text/javascript">
$(function() {
$("#forwards").click(function() {
$('#ball').fadeOut(function() {
$('#ball2').moving();
});
});
}); //end ready
</script>
</body>
</html>
I've also tried the following code
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("#button").click(function() {
jQuery("#stone").addClass("reveal");
jQuery("#controls").addClass("fade_button");
});
});
</script>
@charset "utf-8";
/* CSS Document */
#ball {
height: 200px;
width: 200px;
border-top: 2px solid red;
border-right: 2px solid green;
border-bottom: 2px solid yellow;
border-left: 2px solid blue;
border-radius: 100%;
opacity: 1;
margin: 200px 200px;
}
#ball2 {
height: 200px;
width: 200px;
border-top: 2px solid red;
border-right: 2px solid green;
border-bottom: 2px solid yellow;
border-left: 2px solid blue;
border-radius: 100%;
opacity: 1;
}
.controls {
top: 10px;
position: fixed;
}
.moving {
animation: moving 6s;
animation-timing-function: ease-in-out;
animation-fill-mode: forwards;
}
@keyframes moving {
from { transform: translateX(0px) rotate(0deg); }
to { transform: translateX(1000px) rotate(360deg); }
}
.fadeOut {
animation: fadeOut 4s;
animation-delay: 1s;
animation-timing-function: ease-in-out;
animation-fill-mode: forwards;
}
@keyframes fadeOut {
from { opacity: 1; }
to { opacity: 0; }
}
But I can't get it to work. Any help would be appreciated.
(The "proper" page will have quite a complex set of animations so the addClass/removeClass method might be better.
Many thanks