OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <meta charset=utf-8> | |
3 <title>Keyframe handling tests</title> | |
4 <link rel="help" href="https://w3c.github.io/web-animations/#the-effect-value-of
-a-keyframe-animation-effect"> | |
5 <script src="/resources/testharness.js"></script> | |
6 <script src="/resources/testharnessreport.js"></script> | |
7 <script src="../../testcommon.js"></script> | |
8 <body> | |
9 <div id="log"></div> | |
10 <div id="target"></div> | |
11 <script> | |
12 'use strict'; | |
13 | |
14 test(function(t) { | |
15 var div = createDiv(t); | |
16 var anim = div.animate([ { offset: 0, opacity: 0 }, | |
17 { offset: 0, opacity: 0.1 }, | |
18 { offset: 0, opacity: 0.2 }, | |
19 { offset: 1, opacity: 0.8 }, | |
20 { offset: 1, opacity: 0.9 }, | |
21 { offset: 1, opacity: 1 } ], | |
22 { duration: 1000, | |
23 easing: 'cubic-bezier(0.5, -0.5, 0.5, 1.5)' }); | |
24 assert_equals(getComputedStyle(div).opacity, '0.2', | |
25 'When progress is zero the last keyframe with offset 0 should' | |
26 + ' be used'); | |
27 // http://cubic-bezier.com/#.5,-0.5,.5,1.5 | |
28 // At t=0.15, the progress should be negative | |
29 anim.currentTime = 150; | |
30 assert_equals(getComputedStyle(div).opacity, '0', | |
31 'When progress is negative, the first keyframe with a 0 offset' | |
32 + ' should be used'); | |
33 // At t=0.71, the progress should be just less than 1 | |
34 anim.currentTime = 710; | |
35 assert_approx_equals(parseFloat(getComputedStyle(div).opacity), 0.8, 0.01, | |
36 'When progress is just less than 1, the first keyframe with an' | |
37 + ' offset of 1 should be used as the interval endpoint'); | |
38 // At t=0.85, the progress should be > 1 | |
39 anim.currentTime = 850; | |
40 assert_equals(getComputedStyle(div).opacity, '1', | |
41 'When progress is greater than 1.0, the last keyframe with a 1' | |
42 + ' offset should be used'); | |
43 anim.finish(); | |
44 assert_equals(getComputedStyle(div).opacity, '1', | |
45 'When progress is equal to 1.0, the last keyframe with a 1' | |
46 + ' offset should be used'); | |
47 }, 'Overlapping keyframes at 0 and 1 use the appropriate value when the' | |
48 + ' progress is outside the range [0, 1]'); | |
49 | |
50 test(function(t) { | |
51 var div = createDiv(t); | |
52 var anim = div.animate([ { offset: 0, opacity: 0 }, | |
53 { offset: 0.5, opacity: 0.3 }, | |
54 { offset: 0.5, opacity: 0.5 }, | |
55 { offset: 0.5, opacity: 0.7 }, | |
56 { offset: 1, opacity: 1 } ], 1000); | |
57 anim.currentTime = 250; | |
58 assert_equals(getComputedStyle(div).opacity, '0.15', | |
59 'Before the overlap point, the first keyframe from the' | |
60 + ' overlap point should be used as interval endpoint'); | |
61 anim.currentTime = 500; | |
62 assert_equals(getComputedStyle(div).opacity, '0.7', | |
63 'At the overlap point, the last keyframe from the' | |
64 + ' overlap point should be used as interval startpoint'); | |
65 anim.currentTime = 750; | |
66 assert_equals(getComputedStyle(div).opacity, '0.85', | |
67 'After the overlap point, the last keyframe from the' | |
68 + ' overlap point should be used as interval startpoint'); | |
69 }, 'Overlapping keyframes between 0 and 1 use the appropriate value on each' | |
70 + ' side of the overlap point'); | |
71 | |
72 test(function(t) { | |
73 var div = createDiv(t); | |
74 var anim = div.animate({ visibility: ['hidden','visible'] }, | |
75 { duration: 100 * MS_PER_SEC, fill: 'both' }); | |
76 | |
77 anim.currentTime = 0; | |
78 assert_equals(getComputedStyle(div).visibility, 'hidden', | |
79 'Visibility when progress = 0.'); | |
80 | |
81 anim.currentTime = 10 * MS_PER_SEC + 1; | |
82 assert_equals(getComputedStyle(div).visibility, 'visible', | |
83 'Visibility when progress > 0 due to linear easing.'); | |
84 | |
85 anim.finish(); | |
86 assert_equals(getComputedStyle(div).visibility, 'visible', | |
87 'Visibility when progress = 1.'); | |
88 | |
89 }, "Test visibility clamping behavior."); | |
90 | |
91 test(function(t) { | |
92 var div = createDiv(t); | |
93 var anim = div.animate({ visibility: ['hidden', 'visible'] }, | |
94 { duration: 100 * MS_PER_SEC, fill: 'both', | |
95 easing: 'cubic-bezier(0.25, -0.6, 0, 0.5)' }); | |
96 | |
97 anim.currentTime = 0; | |
98 assert_equals(getComputedStyle(div).visibility, 'hidden', | |
99 'Visibility when progress = 0.'); | |
100 | |
101 // Timing function is below zero. So we expected visibility is hidden. | |
102 anim.currentTime = 10 * MS_PER_SEC + 1; | |
103 assert_equals(getComputedStyle(div).visibility, 'hidden', | |
104 'Visibility when progress < 0 due to cubic-bezier easing.'); | |
105 | |
106 anim.currentTime = 60 * MS_PER_SEC; | |
107 assert_equals(getComputedStyle(div).visibility, 'visible', | |
108 'Visibility when progress > 0 due to cubic-bezier easing.'); | |
109 | |
110 }, "Test visibility clamping behavior with an easing that has a negative compone
nt"); | |
111 | |
112 done(); | |
113 </script> | |
114 </body> | |
OLD | NEW |