From e7ac263921c616721b4949ffdafec7616075c0ed Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Wed, 4 Mar 2020 13:57:04 +0800 Subject: [PATCH] iOS:add onScrollEnd --- .../Pod/Classes/Shader/DoricScrollerNode.m | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/doric-iOS/Pod/Classes/Shader/DoricScrollerNode.m b/doric-iOS/Pod/Classes/Shader/DoricScrollerNode.m index e691f15c..c592b992 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricScrollerNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricScrollerNode.m @@ -152,6 +152,30 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView { } } +- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { + if (self.onScrollEndFuncId) { + [self callJSResponse:self.onScrollEndFuncId, + @{ + @"x": @(self.view.contentOffset.x), + @"y": @(self.view.contentOffset.y), + }, + nil]; + } +} + +- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate { + if (!decelerate) { + if (self.onScrollEndFuncId) { + [self callJSResponse:self.onScrollEndFuncId, + @{ + @"x": @(self.view.contentOffset.x), + @"y": @(self.view.contentOffset.y), + }, + nil]; + } + } +} + - (void)scrollTo:(NSDictionary *)params { BOOL animated = [params[@"animated"] boolValue]; NSDictionary *offsetDic = params[@"offset"];