summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/motion/animation/offset-anchor-interpolation.html
blob: 9c69c0f0bed2b14c02091ccf63f50ace61f2eb2a (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>offset-anchor interpolation</title>
    <link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org">
    <link rel="help" href="https://drafts.fxtf.org/motion-1/#offset-anchor-property">
    <meta name="assert" content="offset-anchor supports <position> animation.">
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
    <script src="/css/support/interpolation-testcommon.js"></script>
    <style>
      .parent {
        offset-anchor: 30px 10px;
      }
      .target {
        offset-anchor: 10px 30px;
      }
    </style>
  </head>
  <body>
    <script>
      test_interpolation({
        property: 'offset-anchor',
        from: '220px 240px',
        to: '300px 400px',
      }, [
        {at: -1, expect: '140px 80px'},
        {at: 0, expect: '220px 240px'},
        {at: 0.125, expect: '230px 260px'},
        {at: 0.875, expect: '290px 380px'},
        {at: 1, expect: '300px 400px'},
        {at: 2, expect: '380px 560px'}
      ]);

      test_interpolation({
        property: 'offset-anchor',
        from: 'left 480px top 400px',
        to: 'right -140% bottom -60%',
      }, [
        {at: -1, expect: 'calc(960px - 240%) calc(800px - 160%)'},
        {at: 0, expect: 'left calc(0% + 480px) top calc(0% + 400px)'},
        {at: 0.125, expect: 'calc(420px + 30%) calc(350px + 20%)'},
        {at: 0.875, expect: 'calc(210% + 60px) calc(140% + 50px)'},
        {at: 1, expect: 'right -140% bottom -60%'},
        {at: 2, expect: 'calc(480% - 480px) calc(320% - 400px)'}
      ]);

      test_interpolation({
        property: 'offset-anchor',
        from: 'left top',
        to: 'left 8px bottom 20%',
      }, [
        {at: -1, expect: 'calc(0% - 8px) -80%'},
        {at: 0, expect: 'left top'},
        {at: 0.125, expect: 'calc(0% + 1px) 10%'},
        {at: 0.875, expect: 'calc(0% + 7px) 70%'},
        {at: 1, expect: 'left calc(0% + 8px) bottom 20%'},
        {at: 2, expect: 'calc(0% + 16px) 160%'}
      ]);

      test_no_interpolation({
        property: 'offset-anchor',
        from: 'right 10px top 20%',
        to: 'auto'
      });

      test_interpolation({
        property: 'offset-anchor',
        from: neutralKeyframe,
        to: '20px 20px',
      }, [
        {at: -0.3, expect: '7px 33px'},
        {at: 0, expect: '10px 30px'},
        {at: 0.3, expect: '13px 27px'},
        {at: 0.6, expect: '16px 24px'},
        {at: 1, expect: '20px 20px'},
        {at: 1.5, expect: '25px 15px'},
      ]);

      test_no_interpolation({
        property: 'offset-anchor',
        from: 'initial',
        to: '60% 40%',
      });

      test_interpolation({
        property: 'offset-anchor',
        from: 'inherit',
        to: '20px 20px',
      }, [
        {at: -0.3, expect: '33px 7px'},
        {at: 0, expect: '30px 10px'},
        {at: 0.3, expect: '27px 13px'},
        {at: 0.6, expect: '24px 16px'},
        {at: 1, expect: '20px 20px'},
        {at: 1.5, expect: '15px 25px'},
      ]);

      test_no_interpolation({
        property: 'offset-anchor',
        from: 'unset',
        to: '50% 10px',
      });

      test_interpolation({
        property: 'offset-anchor',
        from: '0% 50%',
        to: '100% 150%'
      }, [
        {at: -0.3, expect: '-30% 20%'},
        {at: 0, expect: '0% 50%'},
        {at: 0.3, expect: '30% 80%'},
        {at: 0.6, expect: '60% 110%'},
        {at: 1, expect: '100% 150%'},
        {at: 1.5, expect: '150% 200%'}
      ]);

      test_no_interpolation({
        property: 'offset-anchor',
        from: 'auto',
        to: '20px 20px',
      });
    </script>
  </body>
</html>