You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ac...@apache.org on 2017/06/08 03:45:49 UTC

incubator-weex git commit: + [ios] bugfix timer & slider

Repository: incubator-weex
Updated Branches:
  refs/heads/0.13-dev 404f3cc14 -> b19047383


+ [ios] bugfix timer & slider


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/b1904738
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/b1904738
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/b1904738

Branch: refs/heads/0.13-dev
Commit: b19047383bd5616dc70d82823db3748e29956078
Parents: 404f3cc
Author: 齐山 <su...@163.com>
Authored: Thu Jun 8 11:30:12 2017 +0800
Committer: 齐山 <su...@163.com>
Committed: Thu Jun 8 11:30:12 2017 +0800

----------------------------------------------------------------------
 ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.m | 9 ++++++---
 ios/sdk/WeexSDK/Sources/Module/WXTimerModule.m             | 4 +++-
 2 files changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/b1904738/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.m
index 517af72..d17b7db 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.m
@@ -109,6 +109,7 @@ typedef NS_ENUM(NSInteger, Direction) {
     if (currentIndex >= _itemViews.count || currentIndex < 0) {
         currentIndex = 0;
     }
+    NSInteger oldIndex = _currentIndex;
     _currentIndex = currentIndex;
     if (_infinite) {
         if (_direction == DirectionRight) {
@@ -130,7 +131,9 @@ typedef NS_ENUM(NSInteger, Direction) {
     }
     [self resetIndicatorPoint];
     if (self.delegate && [self.delegate respondsToSelector:@selector(recycleSliderView:didScrollToItemAtIndex:)]) {
-        [self.delegate recycleSliderView:self didScrollToItemAtIndex:_currentIndex];
+        if (oldIndex != _currentIndex) {
+            [self.delegate recycleSliderView:self didScrollToItemAtIndex:_currentIndex];
+        }
     }
 }
 
@@ -179,7 +182,7 @@ typedef NS_ENUM(NSInteger, Direction) {
         _currentItemFrame = CGRectMake(self.width, 0, self.width, self.height);
         for (int i = 0; i < self.itemViews.count; i++) {
             UIView *view = [self.itemViews objectAtIndex:i];
-            if (i != self.currentIndex && i != self.nextIndex) {
+            if (i != self.currentIndex) {
                 view.frame = CGRectMake(self.frame.size.width * 3, 0, self.width, self.height);;
             }
         }
@@ -587,7 +590,7 @@ typedef NS_ENUM(NSInteger, Direction) {
 - (void)recycleSliderView:(WXRecycleSliderView *)recycleSliderView didScrollToItemAtIndex:(NSInteger)index
 {
     
-    if (_sliderChangeEvent && index != self.currentIndex) {
+    if (_sliderChangeEvent) {
         [self fireEvent:@"change" params:@{@"index":@(index)} domChanges:@{@"attrs": @{@"index": @(index)}}];
         self.currentIndex = index;
     }

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/b1904738/ios/sdk/WeexSDK/Sources/Module/WXTimerModule.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Module/WXTimerModule.m b/ios/sdk/WeexSDK/Sources/Module/WXTimerModule.m
index 26a7481..6855466 100644
--- a/ios/sdk/WeexSDK/Sources/Module/WXTimerModule.m
+++ b/ios/sdk/WeexSDK/Sources/Module/WXTimerModule.m
@@ -128,7 +128,9 @@ WX_EXPORT_METHOD(@selector(clearInterval:))
             NSTimer *timer = _timers[callbackID];
             [timer invalidate];
         }
-        [_timers removeAllObjects];
+        if([_timers count]>0){
+             [_timers removeAllObjects];
+        }
         _timers = nil;
     }
 }