File: effect-value-overlapping-keyframes.html

package info (click to toggle)
thunderbird 1%3A140.4.0esr-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,609,432 kB
  • sloc: cpp: 7,672,442; javascript: 5,901,613; ansic: 3,898,954; python: 1,413,343; xml: 653,997; asm: 462,286; java: 180,927; sh: 113,489; makefile: 20,460; perl: 14,288; objc: 13,059; yacc: 4,583; pascal: 3,352; lex: 1,720; ruby: 1,222; exp: 762; sql: 715; awk: 580; php: 436; lisp: 430; sed: 70; csh: 10
file content (77 lines) | stat: -rw-r--r-- 3,602 bytes parent folder | download | duplicates (28)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!DOCTYPE html>
<meta charset=utf-8>
<title>The effect value of a keyframe effect: Overlapping keyframes</title>
<link rel="help" href="https://drafts.csswg.org/web-animations/#the-effect-value-of-a-keyframe-animation-effect">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../testcommon.js"></script>
<body>
<div id="log"></div>
<div id="target"></div>
<script>
'use strict';

function assert_opacity_value(opacity, expected, description) {
  return assert_approx_equals(parseFloat(opacity), expected, 0.0001, description);
}

test(t => {
  const div = createDiv(t);
  const anim = div.animate([ { offset: 0, opacity: 0 },
                             { offset: 0, opacity: 0.1 },
                             { offset: 0, opacity: 0.2 },
                             { offset: 1, opacity: 0.8 },
                             { offset: 1, opacity: 0.9 },
                             { offset: 1, opacity: 1 } ],
                           { duration: 1000,
                             easing: 'cubic-bezier(0.5, -0.5, 0.5, 1.5)' });
  assert_opacity_value(getComputedStyle(div).opacity, 0.2,
                'When progress is zero the last keyframe with offset 0 should'
                + ' be used');
  // http://cubic-bezier.com/#.5,-0.5,.5,1.5
  // At t=0.15, the progress should be negative
  anim.currentTime = 150;
  assert_equals(getComputedStyle(div).opacity, '0',
                'When progress is negative, the first keyframe with a 0 offset'
                + ' should be used');
  // At t=0.71, the progress should be just less than 1
  anim.currentTime = 710;
  assert_approx_equals(parseFloat(getComputedStyle(div).opacity), 0.8, 0.01,
                'When progress is just less than 1, the first keyframe with an'
                + ' offset of 1 should be used as the interval endpoint');
  // At t=0.85, the progress should be > 1
  anim.currentTime = 850;
  assert_equals(getComputedStyle(div).opacity, '1',
                'When progress is greater than 1.0, the last keyframe with a 1'
                + ' offset should be used');
  anim.finish();
  assert_equals(getComputedStyle(div).opacity, '1',
                'When progress is equal to 1.0, the last keyframe with a 1'
                + ' offset should be used');
}, 'Overlapping keyframes at 0 and 1 use the appropriate value when the'
   + ' progress is outside the range [0, 1]');

test(t => {
  const div = createDiv(t);
  const anim = div.animate([ { offset: 0, opacity: 0 },
                             { offset: 0.5, opacity: 0.3 },
                             { offset: 0.5, opacity: 0.5 },
                             { offset: 0.5, opacity: 0.7 },
                             { offset: 1, opacity: 1 } ], 1000);
  anim.currentTime = 250;
  assert_opacity_value(getComputedStyle(div).opacity, 0.15,
                'Before the overlap point, the first keyframe from the'
                + ' overlap point should be used as interval endpoint');
  anim.currentTime = 500;
  assert_opacity_value(getComputedStyle(div).opacity, 0.7,
                'At the overlap point, the last keyframe from the'
                + ' overlap point should be used as interval startpoint');
  anim.currentTime = 750;
  assert_opacity_value(getComputedStyle(div).opacity, 0.85,
                'After the overlap point, the last keyframe from the'
                + ' overlap point should be used as interval startpoint');
}, 'Overlapping keyframes between 0 and 1 use the appropriate value on each'
   + ' side of the overlap point');

</script>
</body>