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

[GitHub] cxfeng1 closed pull request #1849: [iOS] Slider animation can be forbidden on iOS which is the default b…

cxfeng1 closed pull request #1849: [iOS] Slider animation can be forbidden on iOS which is the default b…
URL: https://github.com/apache/incubator-weex/pull/1849
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.mm b/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.mm
index 4fb0b91489..0bd71bc1b3 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.mm
+++ b/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.mm
@@ -58,6 +58,7 @@ @interface WXRecycleSliderView : UIView <UIScrollViewDelegate>
 @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 @@ - (void)setCurrentIndex:(NSInteger)currentIndex
         }
         [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 @@ - (void)resetAllViewsFrame
 - (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 @@ @interface WXCycleSliderComponent () <WXRecycleSliderViewDelegate,WXIndicatorCom
 @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 @@ - (instancetype)initWithRef:(NSString *)ref type:(NSString *)type styles:(NSDict
             _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 @@ - (void)viewDidLoad
     _recycleSliderView.exclusiveTouch = YES;
     _recycleSliderView.scrollView.scrollEnabled = _scrollable;
     _recycleSliderView.infinite = _infinite;
+    _recycleSliderView.forbidSlideAnimation = _forbidSlideAnimation;
     UIAccessibilityTraits traits = UIAccessibilityTraitAdjustable;
     if (_autoPlay) {
         traits |= UIAccessibilityTraitUpdatesFrequently;
@@ -569,6 +575,11 @@ - (void)willRemoveSubview:(WXComponent *)component
 
 - (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) {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services