animationstart-and-animationend-events-manual.html (1659B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>CSS Animations Test: animation events - animationstart and animationend</title> 4 <link rel="author" title="Nokia Inc." href="http://www.nokia.com"> 5 <link rel="author" title="Intel" href="http://www.intel.com"> 6 <link rel="reviewer" title="Zhiqiang Zhang" href="mailto:zhiqiang.zhang@intel.com"> <!-- 2015-05-06 --> 7 <link rel="help" href="https://drafts.csswg.org/css-animations-1/#animation-name"> 8 <link rel="help" href="https://drafts.csswg.org/css-animations-1/#animation-duration"> 9 <link rel="help" href="https://drafts.csswg.org/css-animations-1/#events"> 10 <meta name="flags" content="animated"> 11 <meta name="assert" content="Check that animationstart event occurs at the start of an animation, 12 animationend event occurs when animation finishes."> 13 <style> 14 div { 15 animation-name: sample; 16 animation-duration: 10s; 17 18 background-color: blue; 19 height: 100px; 20 width: 100px; 21 position: relative; 22 } 23 24 @keyframes sample { 25 from { 26 left: 150px; 27 } 28 to { 29 left: 0px; 30 } 31 } 32 </style> 33 <body> 34 <p> 35 Test passes if there is a filled blue square, 36 which moves from right to left with text 'START' 37 and changes to 'END' when the animation is finished. 38 </p> 39 <div>Filler Text</div> 40 <script> 41 var div = document.getElementsByTagName("div"); 42 div[0].addEventListener("animationstart", animationStart, true); 43 div[0].addEventListener("animationend", animationEnd, true); 44 45 function animationStart() { 46 div[0].innerHTML = "START"; 47 } 48 49 function animationEnd() { 50 div[0].innerHTML = "END"; 51 } 52 </script> 53 </body>