Repository: incubator-weex
Updated Branches:
  refs/heads/master 75d5cd6ba -> 39f539ab6


[WEEX-102][iOS]bugfix appear event will fire wrongly while the view has not 
been loaded

 if the view has not been loaded or has not been added to its scroller view, it 
should not be
notified appear event, because it cannot scroll to  appear area as the 
scrollview scroll.

Bug:102


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

Branch: refs/heads/master
Commit: f77f9cc35adc53c527853f898589fe6418ed4781
Parents: 6617a0d
Author: acton393 <[email protected]>
Authored: Thu Nov 16 15:33:17 2017 +0800
Committer: acton393 <[email protected]>
Committed: Thu Nov 16 15:33:17 2017 +0800

----------------------------------------------------------------------
 .../Sources/Component/WXScrollerComponent.m      | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f77f9cc3/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.m 
b/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.m
index 99ae5b3..9995e89 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.m
@@ -26,6 +26,8 @@
 #import "WXUtility.h"
 #import "WXLoadingComponent.h"
 #import "WXRefreshComponent.h"
+#import "WXConfigCenterProtocol.h"
+#import "WXSDKEngine.h"
 
 @interface WXScrollerComponnetView:UIScrollView
 @end
@@ -78,6 +80,8 @@
     NSString *_direction;
     BOOL _showScrollBar;
     BOOL _pagingEnabled;
+    
+    BOOL _shouldNotifiAppearDescendantView;
 
     css_node_t *_scrollerCSSNode;
     
@@ -142,6 +146,12 @@ WX_EXPORT_METHOD(@selector(resetLoadmore))
              self.cssNode->style.flex <= 0.0) {
             self.cssNode->style.flex = 1.0;
         }
+        id configCenter = [WXSDKEngine 
handlerForProtocol:@protocol(WXConfigCenterProtocol)];
+        if ([configCenter 
respondsToSelector:@selector(configForKey:defaultValue:isDefault:)]) {
+            BOOL shouldNotifiAppearDescendantView = [[configCenter 
configForKey:@"iOS_weex_ext_config.shouldNotifiAppearDescendantView" 
defaultValue:@(YES) isDefault:NULL] boolValue];
+            _shouldNotifiAppearDescendantView = 
shouldNotifiAppearDescendantView;
+            
+        }
     }
     
     return self;
@@ -604,7 +614,14 @@ WX_EXPORT_METHOD(@selector(resetLoadmore))
     // notify action for appear
     NSArray *listenerArrayCopy = [self.listenerArray copy];
     for(WXScrollToTarget *target in listenerArrayCopy){
-        [self scrollToTarget:target scrollRect:scrollRect];
+        if (_shouldNotifiAppearDescendantView) {
+            // if target component is descendant of scrollerview, it should 
notify the appear event handler, or here will skip this appear calculation.
+            if ([target.target isViewLoaded] && [target.target.view 
isDescendantOfView:self.view]) {
+                [self scrollToTarget:target scrollRect:scrollRect];
+            }
+        } else {
+            [self scrollToTarget:target scrollRect:scrollRect];
+        }
     }
 }
 

Reply via email to