Skip to content

Commit

Permalink
Add velocity and targetContentOffset for scrollEndDrag event in RCTSc…
Browse files Browse the repository at this point in the history
…rollView

Summary:
In some case, it is very useful to have `velocity` and `targetContentOffset` parameters for `ScrollEndDrag` event. I just added them.
Closes #1500
Github Author: =?UTF-8?q?=E6=AD=A3=E9=9C=96?= <zhenglin.lzl@alibaba-inc.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
  • Loading branch information
=?UTF-8?q?=E6=AD=A3=E9=9C=96?= committed Jun 15, 2015
1 parent df8287d commit 3940b02
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion React/Views/RCTScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,17 @@ - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView

- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
{
[_eventDispatcher sendScrollEventWithType:RCTScrollEventTypeEnd reactTag:self.reactTag scrollView:scrollView userData:nil];
NSDictionary *userData = @{
@"velocity": @{
@"x": @(velocity.x),
@"y": @(velocity.y)
},
@"targetContentOffset": @{
@"x": @(targetContentOffset->x),
@"y": @(targetContentOffset->y)
}
};
[_eventDispatcher sendScrollEventWithType:RCTScrollEventTypeEnd reactTag:self.reactTag scrollView:scrollView userData:userData];
RCT_FORWARD_SCROLL_EVENT(scrollViewWillEndDragging:scrollView withVelocity:velocity targetContentOffset:targetContentOffset);
}

Expand Down

0 comments on commit 3940b02

Please sign in to comment.