Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

[iOS] Fix issue that PageX, PageY are incorrect when view is in scrol… #2113

Merged
merged 1 commit into from
Feb 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m
Original file line number Diff line number Diff line change
Expand Up @@ -967,9 +967,24 @@ - (void)fireTouchEvent:(NSString *)eventName withTouches:(NSSet<UITouch *> *)tou
{
NSMutableArray *resultTouches = [NSMutableArray new];

CGPoint accmOffset = CGPointZero;
UIView* rootView = _component.weexInstance.rootView;
UIView* view = self.view;
while (view && view != rootView) {
if ([view isKindOfClass:[UIScrollView class]]) {
CGPoint offset = ((UIScrollView*)view).contentOffset;
accmOffset.x += offset.x;
accmOffset.y += offset.y;
}
view = view.superview;
}

for (UITouch *touch in touches) {
CGPoint screenLocation = [touch locationInView:touch.window];
CGPoint pageLocation = [touch locationInView:_component.weexInstance.rootView];
CGPoint pageLocation = [touch locationInView:rootView];
pageLocation.x += accmOffset.x;
pageLocation.y += accmOffset.y;

if (!touch.wx_identifier) {
touch.wx_identifier = @(_touchIdentifier++);
}
Expand Down