You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by cx...@apache.org on 2018/11/30 08:16:33 UTC

[incubator-weex] branch master updated: [iOS] Slider animation can be forbidden on iOS which is the default behavior of Android. (#1849)

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

cxfeng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-weex.git


The following commit(s) were added to refs/heads/master by this push:
     new fe6f8c9  [iOS] Slider animation can be forbidden on iOS which is the default behavior of Android. (#1849)
fe6f8c9 is described below

commit fe6f8c9a14bb484ef6787cc6a54dd74af84661bd
Author: wqyfavor <wq...@163.com>
AuthorDate: Fri Nov 30 16:16:29 2018 +0800

    [iOS] Slider animation can be forbidden on iOS which is the default behavior of Android. (#1849)
---
 .../WeexSDK/Sources/Component/WXCycleSliderComponent.mm | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.mm b/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.mm
index 4fb0b91..0bd71bc 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.mm
+++ b/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.mm
@@ -58,6 +58,7 @@ typedef NS_ENUM(NSInteger, Direction) {
 @property (nonatomic, assign) CGRect currentItemFrame;
 @property (nonatomic, assign) CGRect nextItemFrame;
 @property (nonatomic, assign) BOOL infinite;
+@property (nonatomic, assign) BOOL forbidSlideAnimation;
 
 - (void)insertItemView:(UIView *)view atIndex:(NSInteger)index;
 - (void)removeItemView:(UIView *)view;
@@ -168,7 +169,7 @@ typedef NS_ENUM(NSInteger, Direction) {
         }
         [self resetAllViewsFrame];
     } else {
-        [_scrollView setContentOffset:CGPointMake(_currentIndex * self.width, 0) animated:YES];
+        [_scrollView setContentOffset:CGPointMake(_currentIndex * self.width, 0) animated:!_forbidSlideAnimation];
     }
     [self resetIndicatorPoint];
     if (self.delegate && [self.delegate respondsToSelector:@selector(recycleSliderView:didScrollToItemAtIndex:)]) {
@@ -248,12 +249,12 @@ typedef NS_ENUM(NSInteger, Direction) {
 - (void)nextPage {
     if (_itemViews.count > 1) {
         if (_infinite) {
-            [self.scrollView setContentOffset:CGPointMake(self.width * 2, 0) animated:YES];
+            [self.scrollView setContentOffset:CGPointMake(self.width * 2, 0) animated:!_forbidSlideAnimation];
         } else {
             // the currentindex will be set at the end of animation
             NSInteger nextIndex = self.currentIndex + 1;
             if(nextIndex < _itemViews.count) {
-                [self.scrollView setContentOffset:CGPointMake(nextIndex * self.width, 0) animated:YES];
+                [self.scrollView setContentOffset:CGPointMake(nextIndex * self.width, 0) animated:!_forbidSlideAnimation];
             }
         }
     }
@@ -391,6 +392,7 @@ typedef NS_ENUM(NSInteger, Direction) {
 @property (nonatomic, strong) NSMutableArray *childrenView;
 @property (nonatomic, assign) BOOL scrollable;
 @property (nonatomic, assign) BOOL infinite;
+@property (nonatomic, assign) BOOL forbidSlideAnimation;
 
 @end
 
@@ -426,6 +428,9 @@ typedef NS_ENUM(NSInteger, Direction) {
             _offsetXAccuracy = [WXConvert CGFloat:attributes[@"offsetXAccuracy"]];
         }
         _infinite = attributes[@"infinite"] ? [WXConvert BOOL:attributes[@"infinite"]] : YES;
+        
+        _forbidSlideAnimation = attributes[@"forbidSlideAnimation"] ? [WXConvert BOOL:attributes[@"forbidSlideAnimation"]] : NO;
+        
         self.flexCssNode->setFlexDirection(WeexCore::kFlexDirectionRow,NO);
     }
     return self;
@@ -446,6 +451,7 @@ typedef NS_ENUM(NSInteger, Direction) {
     _recycleSliderView.exclusiveTouch = YES;
     _recycleSliderView.scrollView.scrollEnabled = _scrollable;
     _recycleSliderView.infinite = _infinite;
+    _recycleSliderView.forbidSlideAnimation = _forbidSlideAnimation;
     UIAccessibilityTraits traits = UIAccessibilityTraitAdjustable;
     if (_autoPlay) {
         traits |= UIAccessibilityTraitUpdatesFrequently;
@@ -569,6 +575,11 @@ typedef NS_ENUM(NSInteger, Direction) {
 
 - (void)updateAttributes:(NSDictionary *)attributes
 {
+    if (attributes[@"forbidSlideAnimation"]) {
+        _forbidSlideAnimation = [WXConvert BOOL:attributes[@"forbidSlideAnimation"]];
+        _recycleSliderView.forbidSlideAnimation = _forbidSlideAnimation;
+    }
+    
     if (attributes[@"autoPlay"]) {
         _autoPlay = [WXConvert BOOL:attributes[@"autoPlay"]];
         if (_autoPlay) {