Skip to content

Commit 0575bcb

Browse files
committed
fix: sending event on scrollViewDidEndDecelerating
1 parent 6509db8 commit 0575bcb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ios/ReactNativePageView.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ - (instancetype)initWithEventDispatcher:(id<RCTEventDispatcherProtocol>)eventDis
3636
_dismissKeyboard = UIScrollViewKeyboardDismissModeNone;
3737
_coalescingKey = 0;
3838
_eventDispatcher = eventDispatcher;
39-
_overdrag = NO;
4039
[self embed];
4140
}
4241
return self;
@@ -153,18 +152,19 @@ - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
153152
}
154153

155154
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset {
156-
int position = [self getCurrentPage];
157155
[self.eventDispatcher sendEvent:[[RCTOnPageScrollStateChanged alloc] initWithReactTag:self.reactTag state:@"settling" coalescingKey:_coalescingKey++]];
158-
159-
[self.eventDispatcher sendEvent:[[RCTOnPageSelected alloc] initWithReactTag:self.reactTag position:[NSNumber numberWithInt:position] coalescingKey:_coalescingKey++]];
160156
}
161157

162158
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
159+
int position = [self getCurrentPage];
163160
[self.eventDispatcher sendEvent:[[RCTOnPageScrollStateChanged alloc] initWithReactTag:self.reactTag state:@"idle" coalescingKey:_coalescingKey++]];
161+
162+
[self.eventDispatcher sendEvent:[[RCTOnPageSelected alloc] initWithReactTag:self.reactTag position:[NSNumber numberWithInt:position] coalescingKey:_coalescingKey++]];
164163
}
165164

166165
-(void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {
167166
int position = [self getCurrentPage];
167+
NSLog(@"position scrollViewDidEndScrollingAnimation %d", position);
168168

169169
[self.eventDispatcher sendEvent:[[RCTOnPageSelected alloc] initWithReactTag:self.reactTag position:[NSNumber numberWithInt:position] coalescingKey:_coalescingKey++]];
170170
}

0 commit comments

Comments
 (0)