I would like to create an animation with a “chain” that moves the div element on the screen to two different points on the screen using two consecutive steps.
So, if my div starts with (0,0), I would like this div to come to life and move in the (100,100) direction after 2 seconds. After he reaches the last destination, he will come to life again and move to the point (200, 200) in 3 seconds.
Using -webkit-animation I can do one translation or animation, but I can’t link the second animation that starts after the first one ends, because I don’t have a handle (event or css class) that can give me such information.
I am happy to use some javascript magic as part of the solution.
Here is some code to visualize what I'm trying to do:
HTML:
<div id="box"></div>
CSS
body {
position: relative;
}
#box {
width: 64px;
height: 64px;
position: absolute;
text-indent: -9999px;
}
.translate1 {
-webkit-transform: translate(100px, 100px);
-webkit-transition: all 2s ease-in;
}
.translate2 {
-webkit-transform: translate(100px, 100px);
-webkit-transition: all 23 ease-in;
}
Javascript
$('#box').click(function(){ $(this).addClass('translate1') });
Edit: I get a solution that uses -webkit-animation, because currently it is the best way to display smooth native animation in osx
source
share