fix(ios): ViewPager onPageScrollStateChange missing

settling/dragging status
This commit is contained in:
jonasluo
2022-08-29 18:24:32 +08:00
committed by Zoom Chan
parent ddd45c46d7
commit 8f4ecba634
2 changed files with 9 additions and 4 deletions
@@ -64,6 +64,7 @@ export default class PagerExample extends React.Component {
constructor(props) {
super(props);
this.onPageSelected = this.onPageSelected.bind(this);
this.onPageScrollStateChanged = this.onPageScrollStateChanged.bind(this);
}
onPageSelected(pageData) {
@@ -106,6 +107,7 @@ export default class PagerExample extends React.Component {
keyboardDismissMode="none"
scrollEnabled
onPageSelected={this.onPageSelected}
onPageScrollStateChanged={this.onPageScrollStateChanged}
onPageScroll={this.onPageScroll}
>
{
+7 -4
View File
@@ -163,10 +163,6 @@
#pragma mark scrollview delegate methods
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (self.onPageScrollStateChanged) {
NSString *state = scrollView.isDragging ? @"dragging" : @"settling";
self.onPageScrollStateChanged(@{ @"pageScrollState": state });
}
CGFloat currentContentOffset = self.contentOffset.x;
CGFloat offset = currentContentOffset - self.previousStopOffset;
@@ -211,6 +207,9 @@
[scrollViewListener scrollViewWillBeginDragging:scrollView];
}
}
if (self.onPageScrollStateChanged) {
self.onPageScrollStateChanged(@{ @"pageScrollState": @"dragging" });
}
}
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset {
@@ -233,6 +232,10 @@
if (!decelerate) {
self.isScrolling = NO;
}
if (self.onPageScrollStateChanged) {
NSString *state = decelerate ? @"settling" : @"idle";
self.onPageScrollStateChanged(@{ @"pageScrollState": state });
}
}
- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView {