Add velocity and targetContentOffset for scrollEndDrag event in RCTScrollView
Summary: In some case, it is very useful to have `velocity` and `targetContentOffset` parameters for `ScrollEndDrag` event. I just added them. Closes https://github.com/facebook/react-native/pull/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.
This commit is contained in:
parent
df8287d8ee
commit
3940b024a0
|
@ -581,7 +581,17 @@ RCT_SCROLL_EVENT_HANDLER(scrollViewDidZoom, RCTScrollEventTypeMove)
|
|||
|
||||
- (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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue