Skip to content

Commit

Permalink
fix: set value directly instead of scrollTo
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilson Lau committed Nov 6, 2023
1 parent 64ad98c commit e59ab30
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/components/MainCarousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,10 @@ export default function MainCarousel() {
)

useLayoutEffect(() => {
scrollContainerRef.current?.scrollTo({
left: scrollContainerRef.current?.offsetWidth,
})
if (scrollContainerRef?.current) {
scrollContainerRef.current.scrollLeft =
scrollContainerRef.current.offsetWidth
}
}, [currentSlide])

useEffect(() => {
Expand Down

0 comments on commit e59ab30

Please sign in to comment.