File: view-timeline-with-transform-on-subject.html

package info (click to toggle)
thunderbird 1%3A143.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 4,703,968 kB
  • sloc: cpp: 7,770,492; javascript: 5,943,842; ansic: 3,918,754; python: 1,418,263; xml: 653,354; asm: 474,045; java: 183,079; sh: 111,238; makefile: 20,410; perl: 14,359; objc: 13,059; yacc: 4,583; pascal: 3,405; lex: 1,720; ruby: 999; exp: 762; sql: 715; awk: 580; php: 436; lisp: 430; sed: 69; csh: 10
file content (76 lines) | stat: -rw-r--r-- 2,078 bytes parent folder | download | duplicates (17)
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="help" src="https://drafts.csswg.org/scroll-animations-1/#named-timeline-range">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/web-animations/testcommon.js"></script>
<script src="support/testcommon.js"></script>
<title>Animation range and delay</title>
</head>
<style type="text/css">
  @keyframes anim {
    from { transform: scaleX(0) translateY(0); }
    to { transform: scaleX(1) translatey(50vh); }
  }
  #scroller {
    border:  10px solid lightgray;
    overflow-y: scroll;
    overflow-x: hidden;
    width: 300px;
    height: 200px;
  }
  .spacer {
    height: 200px;
  }
  #target {
    height: 50px;
    background-color: green;
    animation: anim auto both linear;
    animation-timeline: view();
    animation-range-start: contain 0%;
    animation-range-end: contain 100%;
  }
</style>
<body>
  <div id=scroller>
    <div class="spacer"></div>
    <div id="target"></div>
    <div class="spacer"></div>
  </div>
</body>
<script type="text/javascript">
  async function runTest() {
    function assert_progress_equals(anim, expected, errorMessage) {
      assert_approx_equals(
          anim.effect.getComputedTiming().progress,
          expected, 1e-6, errorMessage);
    }

    promise_test(async t => {
      await waitForNextFrame();
      const anim = document.getAnimations()[0];
      await anim.ready;
      await waitForNextFrame();

      // @ contain 0%
      scroller.scrollTop = 50;
      await waitForNextFrame();
      assert_progress_equals(anim, 0, 'progress at contain 0%');

      // @ contain 50%
      scroller.scrollTop = 125;
      await waitForNextFrame();
      assert_progress_equals(anim, 0.5, 'progress at contain 50%');

      // @ contain 100%
      scroller.scrollTop = 200;
      await waitForNextFrame();
      assert_progress_equals(anim, 1, 'progress at contain 100%');
    }, 'ViewTimeline use untransformed box for range calculations');
  }

  window.onload = runTest;
</script>
</html>