This is an automated email from the ASF dual-hosted git repository.

moshen pushed a commit to branch wqyfavor-patch-1
in repository https://gitbox.apache.org/repos/asf/incubator-weex.git

commit 7bb97fc6035864f2801f8cce27d71dcd3ae872d1
Author: wqyfavor <[email protected]>
AuthorDate: Tue Oct 8 21:52:52 2019 +0800

    [iOS] Fix slider crash on iOS9
---
 .../WeexSDK/Sources/Component/WXCycleSliderComponent.mm  | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.mm 
b/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.mm
index d3ba26c..5519de8 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.mm
+++ b/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.mm
@@ -148,10 +148,6 @@ typedef NS_ENUM(NSInteger, Direction) {
 
 - (void)setCurrentIndex:(NSInteger)currentIndex
 {
-    if (_currentIndex == currentIndex) {
-        return;
-    }
-    
     if (currentIndex >= _itemViews.count || currentIndex < 0) {
         currentIndex = 0;
     }
@@ -368,12 +364,24 @@ typedef NS_ENUM(NSInteger, Direction) {
 }
 
 - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {
+    /* In this case, we forbid animation temporarily so that
+     setContentOffset in setCurrentIndex won't cause endless loop
+     on some devices.
+     We have to use _forbidSlideAnimation in setCurrentIndex because
+     sometimes JS will trigger the slider to slide to some posistion
+     with animation.
+     */
+    BOOL oldValue = _forbidSlideAnimation;
+    _forbidSlideAnimation = YES;
+    
     if (_infinite) {
         [self resetScrollView];
     } else {
         NSInteger index = _scrollView.contentOffset.x / self.width;
         [self setCurrentIndex:index];
     }
+        
+    _forbidSlideAnimation = oldValue;
 }
 
 @end

Reply via email to