From 5235c47a3f944e9a558c8a03d76c9cde3c0448d5 Mon Sep 17 00:00:00 2001 From: "kongjing@dian.so" Date: Tue, 1 Nov 2022 11:22:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20swiper=E5=9E=82=E7=9B=B4=E6=96=B9?= =?UTF-8?q?=E5=90=91bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/vantui/src/swiper/swiper.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/vantui/src/swiper/swiper.tsx b/packages/vantui/src/swiper/swiper.tsx index 8870f9969..bb61d06ad 100644 --- a/packages/vantui/src/swiper/swiper.tsx +++ b/packages/vantui/src/swiper/swiper.tsx @@ -435,15 +435,11 @@ const Swiper = ( }, [isVertical, width, height, offset, ready]) useEffect(() => { - if (ready) { - stopAutoPlay() - autoplay() - } return () => { setReady(false) } // eslint-disable-next-line react-hooks/exhaustive-deps - }, [ready]) + }, []) useEffect(() => { stopAutoPlay() @@ -463,9 +459,11 @@ const Swiper = ( }, []) useReady(() => { + init() Taro.nextTick(() => { setTimeout(() => { - init() + stopAutoPlay() + autoplay() }, 16) }) }) @@ -478,6 +476,7 @@ const Swiper = ( style[_direction === 'horizontal' ? 'width' : 'height'] = `${_size}px` } const offset = childOffset[index] + if (offset) { style.transform = `translate3D${ _direction === 'horizontal' ? `(${offset}px,0,0)` : `(0,${offset}px,0)`