Skip to content

Commit

Permalink
perf(ios): no need to cancel gesture if gesture exists
Browse files Browse the repository at this point in the history
  • Loading branch information
ozonelmy authored and hippy-actions[bot] committed Aug 28, 2023
1 parent 1303783 commit 6f2893f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion renderer/native/ios/renderer/NativeRenderImpl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,7 @@ - (void)createRenderNodes:(std::vector<std::shared_ptr<DomNode>> &&)nodes
NativeRenderObjectView *subRenderObject = [self->_renderObjectRegistry componentForTag:@(subviewTags[index]) onRootTag:rootNodeTag];
[superRenderObject insertNativeRenderSubview:subRenderObject atIndex:subviewIndices[index]];
}
[superRenderObject didUpdateNativeRenderSubviews];
}];
for (const std::shared_ptr<DomNode> &node : nodes) {
NSNumber *componentTag = @(node->GetId());
Expand All @@ -780,7 +781,9 @@ - (void)createRenderNodes:(std::vector<std::shared_ptr<DomNode>> &&)nodes
UIView *superView = viewRegistry[@(tag)];
for (NSUInteger index = 0; index < subViewTags_.size(); index++) {
UIView *subview = viewRegistry[@(subViewTags_[index])];
[superView insertNativeRenderSubview:subview atIndex:subViewIndices_[index]];
if (subview) {
[superView insertNativeRenderSubview:subview atIndex:subViewIndices_[index]];
}
}
[superView clearSortedSubviews];
[superView didUpdateNativeRenderSubviews];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,13 @@ - (void)removeViewEvent:(NativeRenderViewEventType)touchEvent {
if (NativeRenderViewEventTypeClick == touchEvent) {
if (_tapGestureRecognizer) {
[self removeGestureRecognizer:_tapGestureRecognizer];
_tapGestureRecognizer = nil;
}
}
else if (NativeRenderViewEventTypeLongClick == touchEvent) {
if (_longGestureRecognizer) {
[self removeGestureRecognizer:_longGestureRecognizer];
_longGestureRecognizer = nil;
}
}
else if (NativeRenderViewEventTypePressIn == touchEvent) {
Expand Down Expand Up @@ -198,7 +200,7 @@ - (void)setTouchEventListener:(OnTouchEventHandler)eventListener forEvent:(Nativ

- (void)addClickEventListener:(OnTouchEventHandler)eventListener {
if (_tapGestureRecognizer) {
[self removeGestureRecognizer:_tapGestureRecognizer];
return;
}
_tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleClickEvent)];
_tapGestureRecognizer.cancelsTouchesInView = NO;
Expand All @@ -209,7 +211,7 @@ - (void)addClickEventListener:(OnTouchEventHandler)eventListener {

- (void)addLongClickEventListener:(OnTouchEventHandler)eventListener {
if (_longGestureRecognizer) {
[self removeGestureRecognizer:_longGestureRecognizer];
return;
}
_longGestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongClickEvent)];
_longGestureRecognizer.cancelsTouchesInView = NO;
Expand All @@ -218,6 +220,9 @@ - (void)addLongClickEventListener:(OnTouchEventHandler)eventListener {
}

- (void)addPressInEventListener:(OnTouchEventHandler)eventListener {
if (_pressInEventEnabled) {
return;
}
if (_pressInTimer) {
[_pressInTimer invalidate];
}
Expand Down

0 comments on commit 6f2893f

Please sign in to comment.