Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle x/y position for touch in dragstart/dragend events on iOS #14134

Merged
merged 4 commits into from
Oct 17, 2024
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
23 changes: 18 additions & 5 deletions iphone/Classes/TiUIScrollViewProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -430,23 +430,36 @@ - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)vi

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
CGPoint offset = [scrollView contentOffset];
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
NUMFLOAT(offset.x), @"x",
NUMFLOAT(offset.y), @"y",
NUMBOOL([scrollView isDecelerating]), @"decelerating",
[TiUtils sizeToDictionary:scrollView.contentSize], @"contentSize",
nil];
if ([self _hasListeners:@"dragStart"]) { // TODO: Deprecate old event
[self fireEvent:@"dragStart" withObject:nil];
[self fireEvent:@"dragStart" withObject:dict];
}
if ([self _hasListeners:@"dragstart"]) {
[self fireEvent:@"dragstart" withObject:nil];
[self fireEvent:@"dragstart" withObject:dict];
}
}

// listerner which tells when dragging ended in the scroll view.

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
CGPoint offset = [scrollView contentOffset];
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
NUMFLOAT(offset.x), @"x",
NUMFLOAT(offset.y), @"y",
[NSNumber numberWithBool:decelerate], @"decelerate", nil,
[TiUtils sizeToDictionary:scrollView.contentSize], @"contentSize",
nil];
if ([self _hasListeners:@"dragEnd"]) { // TODO: Deprecate old event
[self fireEvent:@"dragEnd" withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:decelerate], @"decelerate", nil]];
[self fireEvent:@"dragEnd" withObject:dict];
}
if ([self _hasListeners:@"dragend"]) {
[self fireEvent:@"dragend" withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:decelerate], @"decelerate", nil]];
[self fireEvent:@"dragend" withObject:dict];
}
}

Expand Down
Loading