File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -89,22 +89,31 @@ const Swiper = (porps: SwiperProps) => {
8989
9090 // 开始拖拽终止定时器
9191 const onScrollBeginDrag = ( ) => {
92- if ( autoplay ) clearInterval ( timer . current as unknown as number ) ;
92+ if ( autoplay ) {
93+ clearInterval ( timer . current as unknown as number ) ;
94+ // setCurIndex(0);
95+ }
9396 } ;
9497
9598 // 停止拖拽开启定时器
9699 const onScrollEndDrag = ( ) => {
97100 if ( autoplay ) autoPlay ( ) ;
98101 } ;
99102
100- // 拖拽成功
101103 const onMomentumScrollEnd = ( e : NativeSyntheticEvent < NativeScrollEvent > ) => {
102104 e . persist ( ) ;
103105 let offSetX = e . nativeEvent . contentOffset . x ;
104106 let mentWidth = e . nativeEvent . layoutMeasurement . width ;
105107 let page = offSetX / mentWidth ;
106- setCurIndex ( page ) ;
108+
109+ if ( page === dataSource . length ) {
110+ setCurIndex ( 0 ) ;
111+ scrollToRef . current . scrollTo ( { x : 0 , y : 0 , animated : false } ) ;
112+ } else {
113+ setCurIndex ( page ) ;
114+ }
107115 } ;
116+
108117 // 点击原点跳转
109118 const onClickDot = ( index : number ) => {
110119 setCurIndex ( index ) ;
@@ -123,7 +132,7 @@ const Swiper = (porps: SwiperProps) => {
123132 onMomentumScrollEnd = { onMomentumScrollEnd }
124133 onContentSizeChange = { onContentSizeChange }
125134 >
126- { dataSource . map ( ( item : dataSourceType , index : number ) => {
135+ { [ ... dataSource , dataSource [ 0 ] ] . map ( ( item : dataSourceType , index : number ) => {
127136 return (
128137 < View key = { index } style = { { width, height } } >
129138 < View style = { { padding : 12 } } >
You can’t perform that action at this time.
0 commit comments