feat:scroller add scrollBy

This commit is contained in:
pengfei.zhou
2020-03-03 13:54:36 +08:00
committed by osborn
parent 6d7562877e
commit 0641f5e223
12 changed files with 73 additions and 8 deletions

View File

@@ -144,4 +144,14 @@ - (void)scrollTo:(NSDictionary *)params {
CGPoint offset = CGPointMake([offsetDic[@"x"] floatValue], [offsetDic[@"y"] floatValue]);
[self.view setContentOffset:offset animated:animated];
}
- (void)scrollBy:(NSDictionary *)params {
BOOL animated = [params[@"animated"] boolValue];
NSDictionary *offsetDic = params[@"offset"];
CGPoint offset = CGPointMake([offsetDic[@"x"] floatValue], [offsetDic[@"y"] floatValue]);
[self.view setContentOffset:CGPointMake(
MIN(self.view.contentSize.width - self.view.width, MAX(0, offset.x + self.view.contentOffset.x)),
MIN(self.view.contentSize.height - self.view.height, MAX(0, offset.y + self.view.contentOffset.y)))
animated:animated];
}
@end