summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/scroll-animations/scroll-timelines/intrinsic-iteration-duration.tentative.html
blob: 4bcea1adba3d8466a9a5d9d5b432a713cc414994 (plain)
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
78
<!doctype html>
<meta charset=utf-8>
<title>Scroll based animation: AnimationEffect.getComputedTiming</title>
<link rel="help" href="https://www.w3.org/TR/web-animations-2/#dom-animationeffect-getcomputedtiming">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/web-animations/testcommon.js"></script>
<script src="testcommon.js"></script>
<style>
  .scroller {
    overflow: auto;
    height: 100px;
    width: 100px;
    will-change: transform;
  }
  .contents {
    height: 1000px;
    width: 100%;
  }
</style>
<body>
<div id="log"></div>
<script type="text/javascript">

//------------------------------------
// Time-based duration
//------------------------------------

test(t => {
  const anim = createScrollLinkedAnimationWithTiming(t, {duration: 1000 });
  assert_equals(anim.effect.getTiming().duration, 1000);
  assert_percents_equal(anim.effect.getComputedTiming().duration, 100);
}, 'Computed duration in percent even when specified in ms');

test(t => {
  const anim = createScrollLinkedAnimationWithTiming(t, { duration: 1000 });
  anim.rangeStart = { offset: CSS.percent(20) };
  anim.rangeEnd = { offset: CSS.percent(80) };
  assert_equals(anim.effect.getTiming().duration, 1000);
  assert_percents_equal(anim.effect.getComputedTiming().duration, 60);
}, 'Time-based duration normalized to fill animation range.');

test(t => {
  const anim =
      createScrollLinkedAnimationWithTiming(
          t, {duration: 700, delay: 100, endDelay: 200 });
  assert_equals(anim.effect.getTiming().duration, 700);
  assert_percents_equal(anim.effect.getComputedTiming().duration, 70);
}, 'Time-based duration normalized to preserve proportional delays.');

//-------------------------------------------------
// Duration 'auto' = Intrinsic iteration duration
//-------------------------------------------------

test(t => {
  const anim = createScrollLinkedAnimationWithTiming(t, {});
  assert_equals(anim.effect.getTiming().duration, 'auto');
  assert_percents_equal(anim.effect.getComputedTiming().duration, 100);
}, 'Intrinsic iteration duration fills timeline.');

test(t => {
  const anim = createScrollLinkedAnimationWithTiming(t, {});
  anim.rangeStart = { offset: CSS.percent(30) };
  anim.rangeEnd = { offset: CSS.percent(90) };
  assert_equals(anim.effect.getTiming().duration, 'auto');
  assert_percents_equal(anim.effect.getComputedTiming().duration, 60);
}, 'Intrinsic iteration duration accounts for animation range.');

test(t => {
  const anim =
      createScrollLinkedAnimationWithTiming(
          t, { iterations: 4 });
  assert_equals(anim.effect.getTiming().duration, 'auto');
  assert_percents_equal(anim.effect.getComputedTiming().duration, 25);
}, 'Intrinsic iteration duration accounts for number of iterations');

</script>
</body>