/
animated.tsx
67 lines (61 loc) · 1.62 KB
/
animated.tsx
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
"use client";
import "animate.css/animate.min.css";
import { LazyImg, VanillaLazyLoad } from "react-vanilla-lazyload";
import WallPaper from "@/app/components/WallPaper.tsx";
const animations = [
"fadeIn",
"fadeInDown",
"fadeInDownBig",
"fadeInLeft",
"fadeInLeftBig",
"fadeInRight",
"fadeInRightBig",
"fadeInUp",
"fadeInUpBig",
"fadeInTopLeft",
"fadeInTopRight",
"fadeInBottomLeft",
"fadeInBottomRight",
"rotateIn",
"rotateInDownLeft",
"rotateInDownRight",
"rotateInUpLeft",
"rotateInUpRight",
"zoomIn",
"zoomInDown",
"zoomInLeft",
"zoomInRight",
"zoomInUp",
"slideInDown",
"slideInLeft",
"slideInRight",
"slideInUp",
];
export default function ImagesLL() {
return (
<>
<WallPaper/>
<p>Example using the onLoad event to add animations to images</p>
{[...Array(40).keys()].map((index) => (
<LazyImg
key={index}
src={`/images/220x280-${String(
index + 1,
).padStart(2, "0")}.webp`}
className={`demo-item lazyItem-${index} hidden`}
alt="random"
title="random"
onLoad={(event) => {
(event.target as HTMLImageElement).classList.add(
"animate__animated",
`animate__${
animations[Math.floor(Math.random() * animations.length)]
}`,
);
}}
/>
))}
<VanillaLazyLoad/>
</>
);
}