File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -22,11 +22,10 @@ const wrappedDistance = (a: number, b: number) => {
22
22
23
23
const setOpacity = ( emblaApi : EmblaCarouselType ) => {
24
24
const slideNodes = emblaApi . slideNodes ( ) ;
25
- const slidesInView = emblaApi . slidesInView ( ) ;
26
25
27
26
const currentPosition = emblaApi . scrollProgress ( ) ;
28
27
29
- slidesInView . forEach ( ( slideIndex ) => {
28
+ slideNodes . forEach ( ( _ , slideIndex ) => {
30
29
const slidePosition = emblaApi . scrollSnapList ( ) [ slideIndex ] ;
31
30
const opacity = clamp (
32
31
1 - wrappedDistance ( slidePosition , currentPosition ) * 8.4 ,
@@ -48,6 +47,7 @@ const Carousel: React.FC<PropType> = ({ slides, options }) => {
48
47
useEffect ( ( ) => {
49
48
if ( ! emblaApi ) return ;
50
49
50
+ setOpacity ( emblaApi ) ;
51
51
emblaApi . on ( "reInit" , setOpacity ) . on ( "scroll" , setOpacity ) ;
52
52
} , [ emblaApi ] ) ;
53
53
You can’t perform that action at this time.
0 commit comments