mirror of
https://github.com/Tencent/Hippy.git
synced 2026-10-29 14:10:47 +08:00
fix(ios): ViewPager onPageScrollStateChange missing
settling/dragging status
This commit is contained in:
@@ -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}
|
||||
>
|
||||
{
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user