summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-01-31 16:43:24 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-01-31 16:43:24 +0700
commit0ca24278cdec32c30a909a10df6680ec4578d932 (patch)
treeb40229468cf092cd0b7e40c2807afb129b26d485 /src
parentad46d122029999b7639657936068c4643f3572eb (diff)
brightness change on slide product
Diffstat (limited to 'src')
-rw-r--r--src/components/products/ProductSlider.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/components/products/ProductSlider.js b/src/components/products/ProductSlider.js
index 4cc98eb7..d52449b8 100644
--- a/src/components/products/ProductSlider.js
+++ b/src/components/products/ProductSlider.js
@@ -4,17 +4,23 @@ import "swiper/css";
import Image from "../elements/Image";
import Link from "../elements/Link";
import { SkeletonProduct } from "../elements/Skeleton";
+import { useEffect, useRef, useState } from "react";
export default function ProductSlider({
products,
bannerMode = false
}) {
+ const [ activeIndex, setActiveIndex ] = useState(0);
+ const swiperSliderFirstMove = (swiper) => {
+ setActiveIndex(swiper.activeIndex);
+ };
+
return (
<>
{ bannerMode && (
- <Image src={products.banner.image} alt={products.banner.name} className="absolute top-0 left-0 h-full max-w-[55%]" />
+ <Image src={products.banner.image} alt={products.banner.name} className={`absolute top-0 left-0 h-full max-w-[55%] idt-transition ` + (activeIndex > 0 ? 'brightness-75' : 'brightness-100')} />
) }
- <Swiper freeMode={true} slidesPerView={2.2} spaceBetween={8}>
+ <Swiper freeMode={true} slidesPerView={2.2} spaceBetween={8} onSlideChange={swiperSliderFirstMove}>
{ bannerMode && (
<SwiperSlide>
<Link href={`/shop/search?category=${products.name}`} className="w-full h-full block"></Link>