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 2019/01/07 12:18:28 UTC

[GitHub] wqyfavor closed pull request #2011: * [iOS] Add support for custom event with stoppropagation

wqyfavor closed pull request #2011: * [iOS] Add support for custom event with stoppropagation
URL: https://github.com/apache/incubator-weex/pull/2011
 
 
   

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/WXComponent_internal.h b/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h
index 00f9450332..376984615d 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h
+++ b/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h
@@ -98,6 +98,7 @@ typedef id (^WXDataBindingBlock)(NSDictionary *data, BOOL *needUpdate);
     BOOL _listenVerticalPan;
     
     BOOL _listenStopPropagation;
+    BOOL _customEvent;
     NSString *_stopPropagationName;
     WXTouchGestureRecognizer* _touchGesture;
     
diff --git a/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m b/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m
index 41be70af21..c98ba3810c 100644
--- a/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m
+++ b/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m
@@ -819,6 +819,10 @@ - (BOOL)gestureShouldStopPropagation:(UIGestureRecognizer *)gestureRecognizer sh
             }
             BOOL stopPropagation = [[WXEventManager sharedManager]stopPropagation:self.weexInstance.instanceId ref:ref type:_stopPropagationName params:@{@"changedTouches":resultTouch ? @[resultTouch] : @[],@"action":touchState}];
             touch.wx_stopPropagation = stopPropagation ? @1 : @0;
+            
+            //only custom event on custom component will make not receive touch
+            //you can use custom-event="yes" to enable this feature
+            return _customEvent ? !stopPropagation : YES;
         }
     }
     return YES;
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXComponent.mm b/ios/sdk/WeexSDK/Sources/Model/WXComponent.mm
index cb7f4dce67..46bed10b29 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXComponent.mm
+++ b/ios/sdk/WeexSDK/Sources/Model/WXComponent.mm
@@ -148,6 +148,10 @@ - (instancetype)initWithRef:(NSString *)ref
             _clipRadius = [WXConvert NSString:attributes[@"clipRadius"]];
         }
         
+        if (attributes[@"customEvent"]) {
+            _customEvent = [WXConvert BOOL:attributes[@"customEvent"]];
+        }
+        
 #ifdef DEBUG
         WXLogDebug(@"flexLayout -> init component: ref : %@ , styles: %@",ref,styles);
         WXLogDebug(@"flexLayout -> init component: ref : %@ , attributes: %@",ref,attributes);


 

----------------------------------------------------------------
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