🐛 bug: carousel

:%s
This commit is contained in:
unknown
2021-08-27 15:57:24 +07:00
parent 162e698efe
commit 33d9ae2615
2 changed files with 11 additions and 8 deletions

View File

@@ -35,14 +35,18 @@ const CarouselCommon = <T,>({
slidesPerView,
slideChanged(s) {
setCurrentSlide(s.details().relativeSlide)
},
afterChange(s) {
let dot = 0
dotArr.forEach((index)=>{
if(s.details().relativeSlide >= Math.floor(index)){
if(s.details().relativeSlide >= index){
dot = index
}
})
console.log(dot)
setDotActive(dot)
},
}
})
useEffect(() => {
@@ -65,7 +69,8 @@ const CarouselCommon = <T,>({
}
const onDotClick = (index:number) => {
slider.moveToSlideRelative(Math.floor(index))
slider.moveToSlideRelative(index)
setDotActive(index)
}
return (
<div className={s.navigationWrapper}>