blob: 8814f63dd171cf473a5716ca56f392adb653577a (
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
|
---
import type { HTMLAttributes } from 'astro/types';
interface Props extends HTMLAttributes<'div'> {
dir?: string;
wrapperClass?: string;
}
const {
dir = "left",
wrapperClass = ""
} = Astro.props;
---
<div class={
`w-full bg-blue-100 flex flex-row gap-2.5 overflow-hidden slider
${dir === "right" ? "reverse" : ""}
${wrapperClass}`}>
<slot />
</div>
<!-- might be cheating a bit using global styles here but at least it lets you use slots -->
<style is:global lang="scss">
$sliderNum: 8;
@for $i from 1 through $sliderNum {
.slider > *:nth-child(#{$i}) {
animation: #{"slide" + $i} 10s linear infinite;
}
@keyframes #{"slide" + $i} {
0% {
transform: translateX(0);
}
#{calc(100% / $sliderNum * $i)} {
transform: translateX(calc((-100% - 10px) * $i));
}
#{calc((100% / $sliderNum * $i) + 0.001%)} {
transform: translateX(calc((100% + 10px) * ($sliderNum - $i)));
}
100% {
transform: translateX(0);
}
}
}
.slider.reverse > * {
animation-direction: reverse;
}
</style>
|