Skip to content

Commit 204a4d3

Browse files
committed
fix: sending event on scrollViewDidEndDecelerating
1 parent 6509db8 commit 204a4d3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

ios/ReactNativePageView.m

Lines changed: 4 additions & 3 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;
@@ -155,16 +154,18 @@ - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
155154
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset {
156155
int position = [self getCurrentPage];
157156
[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++]];
160157
}
161158

162159
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
160+
int position = [self getCurrentPage];
163161
[self.eventDispatcher sendEvent:[[RCTOnPageScrollStateChanged alloc] initWithReactTag:self.reactTag state:@"idle" coalescingKey:_coalescingKey++]];
162+
163+
[self.eventDispatcher sendEvent:[[RCTOnPageSelected alloc] initWithReactTag:self.reactTag position:[NSNumber numberWithInt:position] coalescingKey:_coalescingKey++]];
164164
}
165165

166166
-(void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {
167167
int position = [self getCurrentPage];
168+
NSLog(@"position scrollViewDidEndScrollingAnimation %d", position);
168169

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

0 commit comments

Comments
 (0)