Skip to content

Commit d2b5bd1

Browse files
committed
refactor(scroll-areas): enhance mask-scroller animations and properties
- Introduced custom properties for mask-top and mask-bottom to improve flexibility. - Updated mask styles to utilize gradients for better visual effects. - Enhanced animation support for different scroll timelines, ensuring compatibility with various browsers. Signed-off-by: Innei <tukon479@gmail.com>
1 parent a15190f commit d2b5bd1

File tree

1 file changed

+43
-29
lines changed

1 file changed

+43
-29
lines changed
Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,58 @@
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+
113
.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+
);
1123
}
1224

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))) {
1438
.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();
2444
animation-range:
2545
0 50px,
2646
calc(100% - 50px) 100%;
2747
}
2848
}
2949
@keyframes mask-up {
30-
100% {
31-
mask-size:
32-
100% 30px,
33-
100% 100%,
34-
100% 30px;
50+
to {
51+
--mask-top: 30px;
3552
}
3653
}
3754
@keyframes mask-down {
38-
100% {
39-
mask-size:
40-
100% 30px,
41-
100% 100%,
42-
100% 0;
55+
to {
56+
--mask-bottom: 0px;
4357
}
4458
}

0 commit comments

Comments
 (0)