You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by mo...@apache.org on 2020/08/20 03:05:33 UTC

[incubator-weex] branch master updated: [iOS]fix touch event conflict

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

moshen 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 6b99ced  [iOS]fix touch event conflict
     new a601361  Merge pull request #3258 from jianhan-he/master
6b99ced is described below

commit 6b99cedb90effbe62e926de4e5c1f0163c2fa9a7
Author: linghe.lh <li...@alibaba-inc.com>
AuthorDate: Thu Aug 20 10:17:40 2020 +0800

    [iOS]fix touch event conflict
---
 ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m b/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m
index 34f0c69..d7b594c 100644
--- a/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m
+++ b/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m
@@ -93,6 +93,7 @@
 @property (nonatomic, assign) BOOL listenTouchEnd;
 @property (nonatomic, assign) BOOL listenTouchCancel;
 @property (nonatomic, assign) BOOL listenPseudoTouch;
+@property (nonatomic, assign) NSInteger activeTouches;
 
 - (instancetype)initWithComponent:(WXComponent *)component NS_DESIGNATED_INITIALIZER;
 
@@ -914,6 +915,7 @@ if ([removeEventName isEqualToString:@#eventName1]||[removeEventName isEqualToSt
         _listenTouchEnd = NO;
         _listenTouchMove = NO;
         _listenTouchCancel = NO;
+        _activeTouches = 0;
         
         self.cancelsTouchesInView = NO;
     }
@@ -933,6 +935,10 @@ if ([removeEventName isEqualToString:@#eventName1]||[removeEventName isEqualToSt
         [_component updatePseudoClassStyles:styles];
     }
 
+    _activeTouches += [touches count];
+    if (_activeTouches > (NSInteger)[event.allTouches count]) {
+        _activeTouches = [event.allTouches count];
+    }
 }
 
 - (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
@@ -956,6 +962,11 @@ if ([removeEventName isEqualToString:@#eventName1]||[removeEventName isEqualToSt
         [self recoveryPseudoStyles:_component.styles];
     }
 
+    _activeTouches -= [touches count];
+    if (_activeTouches <= 0) {
+        self.state = UIGestureRecognizerStateEnded;
+        _activeTouches = 0;
+    }
 }
 
 - (void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
@@ -968,6 +979,12 @@ if ([removeEventName isEqualToString:@#eventName1]||[removeEventName isEqualToSt
     if(_listenPseudoTouch) {
         [self recoveryPseudoStyles:_component.styles];
     }
+
+    _activeTouches -= [touches count];
+    if (_activeTouches <= 0) {
+        self.state = UIGestureRecognizerStateEnded;
+        _activeTouches = 0;
+    }
 }
 
 - (void)fireTouchEvent:(NSString *)eventName withTouches:(NSSet<UITouch *> *)touches