dino@apple.com | 19853b3 | 2008-09-11 21:59:08 +0000 | [diff] [blame] | 1 | <html> |
| 2 | <head> |
simon.fraser@apple.com | 4803cdd | 2011-04-26 03:25:14 +0000 | [diff] [blame] | 3 | <style> |
dino@apple.com | 19853b3 | 2008-09-11 21:59:08 +0000 | [diff] [blame] | 4 | .box { |
| 5 | position: relative; |
| 6 | left: 0; |
| 7 | height: 100px; |
| 8 | width: 100px; |
| 9 | margin: 10px; |
| 10 | background-color: blue; |
| 11 | -webkit-transition-property: width, left, background-color, height, top; |
| 12 | -webkit-transition-duration: 0.2s; |
| 13 | } |
| 14 | |
| 15 | .box1 { |
| 16 | left: 50px; |
| 17 | } |
| 18 | |
| 19 | .box2 { |
| 20 | background-color: red; |
| 21 | left: 100px; |
| 22 | } |
| 23 | </style> |
simon.fraser@apple.com | 4803cdd | 2011-04-26 03:25:14 +0000 | [diff] [blame] | 24 | <script src="transition-end-event-helpers.js"></script> |
| 25 | <script type="text/javascript"> |
pol@apple.com | 8ceda8d | 2008-12-19 00:39:21 +0000 | [diff] [blame] | 26 | |
| 27 | var expectedEndEvents = [ |
| 28 | // [property-name, element-id, elapsed-time, listen] |
| 29 | ["left", "box1", 0.2, false], |
dino@apple.com | 19853b3 | 2008-09-11 21:59:08 +0000 | [diff] [blame] | 30 | ]; |
| 31 | |
pol@apple.com | 8ceda8d | 2008-12-19 00:39:21 +0000 | [diff] [blame] | 32 | function startTransition() |
dino@apple.com | 19853b3 | 2008-09-11 21:59:08 +0000 | [diff] [blame] | 33 | { |
| 34 | var box = document.getElementById("box1"); |
| 35 | box.className = "box box2"; |
| 36 | } |
pol@apple.com | 8ceda8d | 2008-12-19 00:39:21 +0000 | [diff] [blame] | 37 | |
abarth@webkit.org | 0b918c2 | 2010-04-08 06:51:00 +0000 | [diff] [blame] | 38 | var firstTimeInHandleEndEvent = true; |
pol@apple.com | 8ceda8d | 2008-12-19 00:39:21 +0000 | [diff] [blame] | 39 | function handleEndEvent(event) |
| 40 | { |
| 41 | recordTransitionEndEvent(event); |
| 42 | |
| 43 | event.target.style.webkitTransitionProperty = "none"; |
abarth@webkit.org | 0b918c2 | 2010-04-08 06:51:00 +0000 | [diff] [blame] | 44 | if (firstTimeInHandleEndEvent) { |
| 45 | firstTimeInHandleEndEvent = false; |
| 46 | window.setTimeout(startTransition, 100); |
| 47 | } |
pol@apple.com | 8ceda8d | 2008-12-19 00:39:21 +0000 | [diff] [blame] | 48 | } |
dino@apple.com | 19853b3 | 2008-09-11 21:59:08 +0000 | [diff] [blame] | 49 | |
pol@apple.com | 8ceda8d | 2008-12-19 00:39:21 +0000 | [diff] [blame] | 50 | function setupTest() |
| 51 | { |
| 52 | var box = document.getElementById("box1"); |
| 53 | box.addEventListener("webkitTransitionEnd", handleEndEvent, false); |
| 54 | box.className = "box box1"; |
| 55 | } |
| 56 | |
eric@webkit.org | baa81d2 | 2010-04-06 23:27:01 +0000 | [diff] [blame] | 57 | // We need to pass an explicit maxTime because we use two sequential |
| 58 | // transitions that each take 0.2s. |
| 59 | runTransitionTest(expectedEndEvents, setupTest, 0.5); |
dino@apple.com | 19853b3 | 2008-09-11 21:59:08 +0000 | [diff] [blame] | 60 | </script> |
| 61 | </head> |
| 62 | <body> |
| 63 | |
| 64 | <p>Initiating transitions on various properties of all boxes.</p> |
| 65 | |
| 66 | <div id="container"> |
| 67 | <div id="box1" class="box"></div> |
| 68 | </div> |
| 69 | |
| 70 | <div id="result"></div> |
| 71 | |
| 72 | </body> |
| 73 | </html> |