This repository was archived by the owner on Jun 3, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
ios/sdk/WeexSDK/Sources/Component Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -148,10 +148,6 @@ - (UIView *)getItemAtIndex:(NSInteger)index
148
148
149
149
- (void )setCurrentIndex : (NSInteger )currentIndex
150
150
{
151
- if (_currentIndex == currentIndex) {
152
- return ;
153
- }
154
-
155
151
if (currentIndex >= _itemViews.count || currentIndex < 0 ) {
156
152
currentIndex = 0 ;
157
153
}
@@ -368,12 +364,24 @@ - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
368
364
}
369
365
370
366
- (void )scrollViewDidEndScrollingAnimation : (UIScrollView *)scrollView {
367
+ /* In this case, we forbid animation temporarily so that
368
+ setContentOffset in setCurrentIndex won't cause endless loop
369
+ on some devices.
370
+ We have to use _forbidSlideAnimation in setCurrentIndex because
371
+ sometimes JS will trigger the slider to slide to some posistion
372
+ with animation.
373
+ */
374
+ BOOL oldValue = _forbidSlideAnimation;
375
+ _forbidSlideAnimation = YES ;
376
+
371
377
if (_infinite) {
372
378
[self resetScrollView ];
373
379
} else {
374
380
NSInteger index = _scrollView.contentOffset .x / self.width ;
375
381
[self setCurrentIndex: index];
376
382
}
383
+
384
+ _forbidSlideAnimation = oldValue;
377
385
}
378
386
379
387
@end
You can’t perform that action at this time.
0 commit comments