|
@@ -3,6 +3,7 @@ import { Box, IconButton } from "@mui/material";
|
3
|
3
|
import ArrowBackIosIcon from "@mui/icons-material/ArrowBackIos";
|
4
|
4
|
import ArrowForwardIosIcon from "@mui/icons-material/ArrowForwardIos";
|
5
|
5
|
import mainImage from "../../assets/images/mainwallpaper.jpg"
|
|
6
|
+import mainImageMobile from "../../assets/images/mainwallpaper-mobile.jpg"
|
6
|
7
|
|
7
|
8
|
const Carousel = () => {
|
8
|
9
|
|
|
@@ -10,6 +11,10 @@ const Carousel = () => {
|
10
|
11
|
{ img_src: mainImage, alt_name: "Image 1" }
|
11
|
12
|
]
|
12
|
13
|
|
|
14
|
+ const items_mobile = [
|
|
15
|
+ { img_src: mainImageMobile, alt_name: "Image 1" }
|
|
16
|
+ ]
|
|
17
|
+
|
13
|
18
|
const [currentIndex, setCurrentIndex] = React.useState(0);
|
14
|
19
|
|
15
|
20
|
const handlePrev = () => {
|
|
@@ -32,21 +37,21 @@ const Carousel = () => {
|
32
|
37
|
alignItems: "center",
|
33
|
38
|
justifyContent: "center",
|
34
|
39
|
width: "100%",
|
35
|
|
- objectPosition:"top center",
|
|
40
|
+ objectPosition: "top center",
|
36
|
41
|
height: "100vh",
|
37
|
42
|
overflow: "hidden",
|
38
|
43
|
}}
|
39
|
44
|
>
|
40
|
45
|
{/* Filter */}
|
41
|
46
|
<Box sx={{
|
42
|
|
- position:"absolute",
|
43
|
|
- top:0,
|
44
|
|
- right:0,
|
45
|
|
- backgroundColor:"rgba(0, 0, 0, 0.3)",
|
46
|
|
- width:"100%",
|
47
|
|
- height:"100%"
|
|
47
|
+ position: "absolute",
|
|
48
|
+ top: 0,
|
|
49
|
+ right: 0,
|
|
50
|
+ backgroundColor: "rgba(0, 0, 0, 0.2)",
|
|
51
|
+ width: "100%",
|
|
52
|
+ height: "100%"
|
48
|
53
|
}}></Box>
|
49
|
|
-
|
|
54
|
+
|
50
|
55
|
{items.map((item, index) => (
|
51
|
56
|
<Box
|
52
|
57
|
key={index}
|
|
@@ -54,44 +59,44 @@ const Carousel = () => {
|
54
|
59
|
src={item.img_src}
|
55
|
60
|
alt={item.alt_name}
|
56
|
61
|
sx={{
|
|
62
|
+ display: {
|
|
63
|
+ xs:"none",
|
|
64
|
+ sm:"none",
|
|
65
|
+ md:"block",
|
|
66
|
+ lg:"block"
|
|
67
|
+ },
|
57
|
68
|
width: "100%",
|
58
|
69
|
height: "100%",
|
59
|
|
- objectFit:"cover",
|
60
|
|
- objectPosition:"center center",
|
61
|
|
- display: index === currentIndex ? "block" : "none",
|
|
70
|
+ backgroundImage: `url(${item.img_src})`,
|
|
71
|
+ objectFit: "cover",
|
|
72
|
+ objectPosition: "center center",
|
62
|
73
|
}}
|
63
|
74
|
/>
|
64
|
75
|
))}
|
65
|
76
|
|
66
|
|
- {/* <IconButton
|
67
|
|
- onClick={handlePrev}
|
68
|
|
- sx={{
|
69
|
|
- position: "absolute",
|
70
|
|
- left: 16,
|
71
|
|
- top: "50%",
|
72
|
|
- transform: "translateY(-50%)",
|
73
|
|
- color: "white",
|
74
|
|
- backgroundColor: "rgba(0, 0, 0, 0.5)",
|
75
|
|
- "&:hover": { backgroundColor: "rgba(0, 0, 0, 0.7)" },
|
76
|
|
- }}
|
77
|
|
- >
|
78
|
|
- <ArrowBackIosIcon />
|
79
|
|
- </IconButton> */}
|
|
77
|
+ {/* Mobile View - Cause the image keep getting wrong offest */}
|
|
78
|
+ {items_mobile.map((item, index) => (
|
|
79
|
+ <Box
|
|
80
|
+ key={index}
|
|
81
|
+ component="img"
|
|
82
|
+ src={item.img_src}
|
|
83
|
+ alt={item.alt_name}
|
|
84
|
+ sx={{
|
|
85
|
+ display: {
|
|
86
|
+ xs:"block",
|
|
87
|
+ sm:"block",
|
|
88
|
+ md:"none",
|
|
89
|
+ lg:"none"
|
|
90
|
+ },
|
|
91
|
+ width: "100%",
|
|
92
|
+ height: "100%",
|
|
93
|
+ backgroundImage: `url(${item.img_src})`,
|
|
94
|
+ objectFit: "cover",
|
|
95
|
+ objectPosition: "center center",
|
|
96
|
+ }}
|
|
97
|
+ />
|
|
98
|
+ ))}
|
80
|
99
|
|
81
|
|
- {/* <IconButton
|
82
|
|
- onClick={handleNext}
|
83
|
|
- sx={{
|
84
|
|
- position: "absolute",
|
85
|
|
- right: 16,
|
86
|
|
- top: "50%",
|
87
|
|
- transform: "translateY(-50%)",
|
88
|
|
- color: "white",
|
89
|
|
- backgroundColor: "rgba(0, 0, 0, 0.5)",
|
90
|
|
- "&:hover": { backgroundColor: "rgba(0, 0, 0, 0.7)" },
|
91
|
|
- }}
|
92
|
|
- >
|
93
|
|
- <ArrowForwardIosIcon />
|
94
|
|
- </IconButton> */}
|
95
|
100
|
</Box>
|
96
|
101
|
);
|
97
|
102
|
};
|