diff --git a/src/App.vue b/src/App.vue index 4674f6ea37aba13ae244f548783ef16cdaa7edc9..404c37215b94e6a6096fb1418cfd970937c44353 100644 --- a/src/App.vue +++ b/src/App.vue @@ -12,7 +12,6 @@ const startTime = performance.now(); const startScroll = Dom.scrollLeft; const duration = 150; - isSnap.value = false; const animate = (timestamp: number) => { const progress = (timestamp - startTime) / duration; if (progress < 1) { @@ -38,6 +37,7 @@ const container = scrollContainer.value const containerWidth = container?.clientWidth || 0; const currentScroll = container?.scrollLeft || 0; + isSnap.value = false; let scrollLeft = 0; if(type==='prev'){ scrollLeft = currentScroll - containerWidth; @@ -46,7 +46,9 @@ } scrollLeft=scrollLeft<0?0:scrollLeft // 有动画 - changeScroll(container as HTMLElement,scrollLeft) + setTimeout(()=>{ + changeScroll(container as HTMLElement, scrollLeft) + },0) } const handleScroll = () => {