@@ -10,6 +10,7 @@ import forwardRefWithStatics from '../_util/forwardRefWithStatics';
1010
1111export interface SwiperProps extends TdSwiperProps , StyledProps {
1212 children ?: React . ReactNode ;
13+ touchable ?: Boolean ;
1314}
1415
1516const Swiper = forwardRefWithStatics (
@@ -29,6 +30,7 @@ const Swiper = forwardRefWithStatics(
2930 className,
3031 style,
3132 children,
33+ touchable = true , // 是否可以通过手势滑动
3234 } = props ;
3335
3436 const { classPrefix } = useConfig ( ) ;
@@ -179,11 +181,15 @@ const Swiper = forwardRefWithStatics(
179181 } , duration + 50 ) ; // 多 50ms 的间隔时间防止动画未执行完就跳转了
180182 } , [ currentIndex , swiperItemLength , duration , direction ] ) ;
181183
182- /** ******************************************************************
183- * 触摸事件处理方法
184- */
185184 // 触摸滑动事件 - 开始
186185 const handleTouchStart = ( e : React . TouchEvent ) => {
186+ if (
187+ ! touchable ||
188+ // avoid resetting position on multi-finger touch
189+ e . touches . length > 1
190+ )
191+ return ;
192+
187193 e . stopPropagation ( ) ;
188194 isHovering . current = true ;
189195 clearTimer ( ) ;
@@ -197,6 +203,7 @@ const Swiper = forwardRefWithStatics(
197203 // 触摸滑动事件 - 滑动中
198204 const handleTouchMove = useCallback (
199205 ( e : React . TouchEvent ) => {
206+ if ( ! touchable ) return ;
200207 e . stopPropagation ( ) ;
201208
202209 if ( moveStartSite ) {
@@ -221,11 +228,12 @@ const Swiper = forwardRefWithStatics(
221228 }
222229 }
223230 } ,
224- [ setTouchMoveDistance , moveStartSite , direction , currentIndex , loop , childrenLength ] ,
231+ [ setTouchMoveDistance , moveStartSite , direction , currentIndex , loop , childrenLength , touchable ] ,
225232 ) ;
226233
227234 // 触摸滑动事件 - 结束
228235 const handleTouchEnd = ( e : React . TouchEvent ) => {
236+ if ( ! touchable ) return ;
229237 e . stopPropagation ( ) ;
230238 if ( touchMoveDistance / swiperOuterWidth <= - 0.3 ) {
231239 // swiperTo(currentIndex + 1, { source: 'touch' });
0 commit comments