File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 11<script lang =" ts" >
2- import { onMount } from ' svelte' ;
2+ import { onDestroy } from ' svelte' ;
33
44 let { images } = $props ();
55 const sliderList = [images [images .length - 1 ], ... images , images [0 ]];
66
77 // Global variables
88 let changeDirection = $state (false );
9- let timeout: ReturnType <typeof setTimeout > = undefined ;
9+ let timeout: ReturnType <typeof setTimeout >;
1010 let currentSlideIndex = $state (1 );
1111 let stopAnimation = $state (false );
1212
13- function changeSlide(slideDirection ) {
13+ function changeSlide(slideDirection : number ) {
1414 if (changeDirection ) return ;
1515 changeDirection = true ;
1616 slideDirection === 1 ? currentSlideIndex ++ : currentSlideIndex -- ;
3131 });
3232 }
3333
34- onMount (() => timeout && clearTimeout (timeout ));
34+ onDestroy (() => timeout && clearTimeout (timeout ));
3535 </script >
3636
3737<div class =" container px-0 relative flex overflow-clip aspect-video" >
5555 alt ={title }
5656 class ={[
5757 ' size-full object-cover translate-x-[calc(-1_*_var(--slide))] transform-gpu shrink-0 motion-safe:transition-transform motion-safe:duration-300' ,
58- stopAnimation && ' motion-safe:transition-none'
58+ stopAnimation && ' motion-safe:transition-none motion-safe:duration-0 '
5959 ]}
6060 />
6161 {/each }
You can’t perform that action at this time.
0 commit comments