From 3940b024a03a5e03d5c6724821439f3c6218e1b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=3D=3FUTF-8=3Fq=3F=3DE6=3DAD=3DA3=3DE9=3D9C=3D96=3F=3D?= Date: Mon, 15 Jun 2015 12:16:07 -0700 Subject: [PATCH] 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?= Test Plan: Imported from GitHub, without a `Test Plan:` line. --- React/Views/RCTScrollView.m | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/React/Views/RCTScrollView.m b/React/Views/RCTScrollView.m index e3f746fb52f952..6c3f5d519c6269 100644 --- a/React/Views/RCTScrollView.m +++ b/React/Views/RCTScrollView.m @@ -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); }