|
| 1 | +@property --mask-top { |
| 2 | + syntax: '<length>'; |
| 3 | + inherits: false; |
| 4 | + initial-value: 0px; |
| 5 | +} |
| 6 | + |
| 7 | +@property --mask-bottom { |
| 8 | + syntax: '<length>'; |
| 9 | + inherits: false; |
| 10 | + initial-value: 30px; |
| 11 | +} |
| 12 | + |
1 | 13 | .mask-scroller { |
2 | | - mask: |
3 | | - linear-gradient(white, transparent) 50% 0 / 100% 0 no-repeat, |
4 | | - linear-gradient(white, white) 50% 50% / 100% 100% no-repeat, |
5 | | - linear-gradient(transparent, white) 50% 100% / 100% 30px no-repeat; |
6 | | - mask-composite: exclude; |
7 | | - mask-size: |
8 | | - 100% calc((var(--scroll-progress-top) / 100) * 30px), |
9 | | - 100% 100%, |
10 | | - 100% calc((100 - (100 * (var(--scroll-progress-bottom) / 100))) * 1px); |
| 14 | + --mask-top: 0px; |
| 15 | + --mask-bottom: 30px; |
| 16 | + mask: linear-gradient( |
| 17 | + to bottom, |
| 18 | + transparent calc(var(--mask-top) - 30px), |
| 19 | + black var(--mask-top), |
| 20 | + black calc(100% - var(--mask-bottom)), |
| 21 | + transparent calc(100% - var(--mask-bottom) + 30px) |
| 22 | + ); |
11 | 23 | } |
12 | 24 |
|
13 | | -@supports (animation-timeline: scroll()) { |
| 25 | +@supports (animation-timeline: scroll(self block)) { |
| 26 | + .mask-scroller { |
| 27 | + animation-name: mask-up, mask-down; |
| 28 | + animation-duration: 1s, 1s; |
| 29 | + animation-timing-function: linear, linear; |
| 30 | + animation-fill-mode: both, both; |
| 31 | + animation-timeline: scroll(self block), scroll(self block); |
| 32 | + animation-range: |
| 33 | + 0 50px, |
| 34 | + calc(100% - 50px) 100%; |
| 35 | + } |
| 36 | +} |
| 37 | +@supports (animation-timeline: scroll()) and (not (animation-timeline: scroll(self block))) { |
14 | 38 | .mask-scroller { |
15 | | - mask: |
16 | | - linear-gradient(white, transparent) 50% 0 / 100% 0 no-repeat, |
17 | | - linear-gradient(white, white) 50% 50% / 100% 100% no-repeat, |
18 | | - linear-gradient(transparent, white) 50% 100% / 100% 30px no-repeat; |
19 | | - mask-composite: exclude; |
20 | | - animation: |
21 | | - mask-up both linear, |
22 | | - mask-down both linear; |
23 | | - animation-timeline: scroll(self); |
| 39 | + animation-name: mask-up, mask-down; |
| 40 | + animation-duration: 1s, 1s; |
| 41 | + animation-timing-function: linear, linear; |
| 42 | + animation-fill-mode: both, both; |
| 43 | + animation-timeline: scroll(), scroll(); |
24 | 44 | animation-range: |
25 | 45 | 0 50px, |
26 | 46 | calc(100% - 50px) 100%; |
27 | 47 | } |
28 | 48 | } |
29 | 49 | @keyframes mask-up { |
30 | | - 100% { |
31 | | - mask-size: |
32 | | - 100% 30px, |
33 | | - 100% 100%, |
34 | | - 100% 30px; |
| 50 | + to { |
| 51 | + --mask-top: 30px; |
35 | 52 | } |
36 | 53 | } |
37 | 54 | @keyframes mask-down { |
38 | | - 100% { |
39 | | - mask-size: |
40 | | - 100% 30px, |
41 | | - 100% 100%, |
42 | | - 100% 0; |
| 55 | + to { |
| 56 | + --mask-bottom: 0px; |
43 | 57 | } |
44 | 58 | } |
0 commit comments