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
|
import React from 'react';
import { useEffect, useState } from 'react';
import './Carousel.css';
import p1 from '/engagement1.webp';
import p2 from '/engagement2.webp';
import p3 from '/engagement3.webp';
import p4 from '/engagement4.webp';
import p5 from '/engagement5.webp';
import p6 from '/engagement6.webp';
import useMediaQuery from '@mui/material/useMediaQuery';
import { AnimatePresence, motion } from 'framer-motion';
function Home() {
const [currentIndex, setIndex] = useState<number>(0);
const photos = [p1, p2, p3, p4, p5, p6];
const isMobile = useMediaQuery('(max-width: 768px)');
useEffect(() => {
const interval = setInterval(() => {
setIndex((prevIndex) => (prevIndex + 1) % photos.length);
}, 5000);
return () => clearInterval(interval);
}, [photos.length]);
return (
<div className="carousel-container">
{isMobile && (
<img
style={{
position: 'absolute',
top: 64,
right: 32,
height: 150,
width: 150,
}}
src="/dove.png"
/>
)}
<div className="carousel">
<AnimatePresence mode="popLayout">
<motion.img
key={photos[currentIndex]}
src={photos[currentIndex]}
alt={`Engagement Photo ${currentIndex + 1}`}
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
transition={{ duration: 2, ease: 'easeInOut' }}
/>
</AnimatePresence>
</div>
{isMobile && (
<img
style={{
position: 'absolute',
bottom: 32,
left: 0,
height: 200,
width: 200,
}}
src="/branch.png"
/>
)}
</div>
);
}
export default Home;
|