feat:scroller add onScroll and onScrollEnd property

This commit is contained in:
pengfei.zhou
2020-03-03 15:51:20 +08:00
committed by osborn
parent 0fa121e54f
commit 021fdab35f
16 changed files with 141 additions and 3 deletions

View File

@@ -51,6 +51,8 @@ - (void)layoutSelf:(CGSize)targetSize {
@interface DoricScrollerNode () <UIScrollViewDelegate>
@property(nonatomic, strong) DoricViewNode *childNode;
@property(nonatomic, copy) NSString *childViewId;
@property(nonatomic, copy) NSString *onScrollFuncId;
@property(nonatomic, copy) NSString *onScrollEndFuncId;
@end
@implementation DoricScrollerNode
@@ -116,6 +118,10 @@ - (void)blend:(NSDictionary *)props {
- (void)blendView:(DoricScrollView *)view forPropName:(NSString *)name propValue:(id)prop {
if ([@"content" isEqualToString:name]) {
self.childViewId = prop;
} else if ([@"onScroll" isEqualToString:name]) {
self.onScrollFuncId = prop;
} else if ([@"onScrollEnd" isEqualToString:name]) {
self.onScrollEndFuncId = prop;
} else {
[super blendView:view forPropName:name propValue:prop];
}
@@ -136,6 +142,14 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (self.didScrollListener) {
self.didScrollListener(scrollView);
}
if (self.onScrollFuncId) {
[self callJSResponse:self.onScrollFuncId,
@{
@"x": @(self.view.contentOffset.x),
@"y": @(self.view.contentOffset.y),
},
nil];
}
}
- (void)scrollTo:(NSDictionary *)params {