@@ -32,7 +32,7 @@ - (instancetype) initWithReactTag:(NSNumber *)reactTag
32
32
coalescingKey : (uint16_t )coalescingKey ;
33
33
{
34
34
RCTAssertParam (reactTag);
35
-
35
+
36
36
if ((self = [super init ])) {
37
37
_viewTag = reactTag;
38
38
_position = position;
@@ -99,7 +99,7 @@ - (instancetype) initWithReactTag:(NSNumber *)reactTag
99
99
coalescingKey : (uint16_t )coalescingKey ;
100
100
{
101
101
RCTAssertParam (reactTag);
102
-
102
+
103
103
if ((self = [super init ])) {
104
104
_viewTag = reactTag;
105
105
_state = state;
@@ -165,7 +165,7 @@ - (instancetype) initWithReactTag:(NSNumber *)reactTag
165
165
coalescingKey : (uint16_t )coalescingKey ;
166
166
{
167
167
RCTAssertParam (reactTag);
168
-
168
+
169
169
if ((self = [super init ])) {
170
170
_viewTag = reactTag;
171
171
_position = position;
@@ -222,7 +222,6 @@ - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher {
222
222
_dismissKeyboard = UIScrollViewKeyboardDismissModeNone;
223
223
_coalescingKey = 0 ;
224
224
_eventDispatcher = eventDispatcher;
225
- _overdrag = YES ;
226
225
}
227
226
return self;
228
227
}
@@ -260,7 +259,7 @@ - (void)addPages {
260
259
_childrenViewControllers = tempChildrenViewControllers;
261
260
_reactPageIndicatorView.numberOfPages = _childrenViewControllers.count ;
262
261
[self goTo: [NSNumber numberWithInteger: _currentIndex] animated: NO ];
263
-
262
+
264
263
} else {
265
264
RCTLog (@" getParentViewController returns nil" );
266
265
}
@@ -272,37 +271,37 @@ - (void)embed {
272
271
dictionaryWithObjectsAndKeys:
273
272
[NSNumber numberWithLong: _pageMargin],
274
273
UIPageViewControllerOptionInterPageSpacingKey, nil ];
275
-
274
+
276
275
UIPageViewController *reactPageViewController =
277
276
[[UIPageViewController alloc ]
278
277
initWithTransitionStyle: _transitionStyle
279
278
navigationOrientation: _orientation
280
279
options: options];
281
-
280
+
282
281
_reactPageViewController = reactPageViewController;
283
282
_reactPageViewController.delegate = self;
284
283
_reactPageViewController.dataSource = self;
285
-
284
+
286
285
for (UIView *subview in _reactPageViewController.view .subviews ) {
287
286
if ([subview isKindOfClass: UIScrollView.class]){
288
287
((UIScrollView *)subview).delegate = self;
289
288
((UIScrollView *)subview).keyboardDismissMode = _dismissKeyboard;
290
289
((UIScrollView *)subview).delaysContentTouches = NO ;
291
290
}
292
291
}
293
-
292
+
294
293
[self renderChildrenViewControllers ];
295
294
_reactPageIndicatorView = [self createPageIndicator: self ];
296
295
_reactPageIndicatorView.hidden = !_showPageIndicator;
297
-
296
+
298
297
[[self reactViewController ] addChildViewController: _reactPageViewController];
299
298
[reactPageViewController.view addSubview: _reactPageIndicatorView];
300
299
[self addSubview: reactPageViewController.view];
301
300
_reactPageViewController.view .frame = [self bounds ];
302
-
301
+
303
302
[_reactPageViewController didMoveToParentViewController: [self reactViewController ]];
304
303
[self shouldScroll: _scrollEnabled];
305
-
304
+
306
305
// Add the page view controller's gesture recognizers to the view controller's view so that the gestures are started more easily.
307
306
self.gestureRecognizers = _reactPageViewController.gestureRecognizers ;
308
307
_reactPageIndicatorView.translatesAutoresizingMaskIntoConstraints = NO ;
@@ -343,7 +342,7 @@ - (void)renderChildrenViewControllers {
343
342
[vc.view removeFromSuperview ];
344
343
}
345
344
[_childrenViewControllers removeAllObjects ];
346
-
345
+
347
346
for (UIView *view in [self reactSubviews ]) {
348
347
[view removeFromSuperview ];
349
348
UIViewController *pageViewController = [self createChildViewController: view];
@@ -374,7 +373,7 @@ - (void)setReactViewControllers:(NSInteger)index
374
373
if (weakSelf.eventDispatcher ) {
375
374
[weakSelf.eventDispatcher sendEvent: [[RCTOnPageSelected alloc ] initWithReactTag: weakSelf.reactTag position: [NSNumber numberWithInteger: index] coalescingKey: coalescingKey]];
376
375
}
377
-
376
+
378
377
}];
379
378
}
380
379
@@ -387,20 +386,20 @@ - (UIViewController *)createChildViewController:(UIView *)view {
387
386
- (void )goTo : (NSNumber *)index animated : (BOOL )animated {
388
387
if (_currentIndex >= 0 &&
389
388
index.integerValue < _childrenViewControllers.count ) {
390
-
389
+
391
390
_reactPageIndicatorView.currentPage = index.integerValue ;
392
391
UIPageViewControllerNavigationDirection direction =
393
392
(index.integerValue > _currentIndex)
394
393
? UIPageViewControllerNavigationDirectionForward
395
394
: UIPageViewControllerNavigationDirectionReverse;
396
-
395
+
397
396
UIViewController *viewController =
398
397
[_childrenViewControllers objectAtIndex: index.integerValue];
399
398
[self setReactViewControllers: index.integerValue
400
399
with: viewController
401
400
direction: direction
402
401
animated: animated];
403
-
402
+
404
403
}
405
404
}
406
405
@@ -426,7 +425,7 @@ - (void)pageViewController:(UIPageViewController *)pageViewController
426
425
UIViewController* currentVC = pageViewController.viewControllers [0 ];
427
426
_currentIndex = [_childrenViewControllers indexOfObject: currentVC];
428
427
[_eventDispatcher sendEvent: [[RCTOnPageSelected alloc ] initWithReactTag: self .reactTag position: [NSNumber numberWithInteger: _currentIndex] coalescingKey: _coalescingKey++]];
429
-
428
+
430
429
[_eventDispatcher sendEvent: [[RCTOnPageScrollEvent alloc ] initWithReactTag: self .reactTag position: [NSNumber numberWithInteger: _currentIndex] offset: [NSNumber numberWithFloat: 0 ] coalescingKey: _coalescingKey++]];
431
430
_reactPageIndicatorView.currentPage = _currentIndex;
432
431
}
@@ -437,13 +436,13 @@ - (UIViewController *)pageViewController:
437
436
(UIPageViewController *)pageViewController
438
437
viewControllerAfterViewController : (UIViewController *)viewController {
439
438
NSUInteger index = [_childrenViewControllers indexOfObject: viewController];
440
-
439
+
441
440
if (index == NSNotFound ) {
442
441
return nil ;
443
442
}
444
-
443
+
445
444
index++;
446
-
445
+
447
446
if (index == [_childrenViewControllers count ]) {
448
447
return nil ;
449
448
}
@@ -456,15 +455,15 @@ - (UIViewController *)pageViewController:
456
455
(UIPageViewController *)pageViewController
457
456
viewControllerBeforeViewController : (UIViewController *)viewController {
458
457
NSUInteger index = [_childrenViewControllers indexOfObject: viewController];
459
-
458
+
460
459
if (index == NSNotFound ) {
461
460
return nil ;
462
461
}
463
-
462
+
464
463
if (index == 0 ) {
465
464
return nil ;
466
465
}
467
-
466
+
468
467
index--;
469
468
return [_childrenViewControllers objectAtIndex: index];
470
469
}
@@ -506,13 +505,6 @@ - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
506
505
}
507
506
508
507
- (void )scrollViewWillEndDragging : (UIScrollView *)scrollView withVelocity : (CGPoint)velocity targetContentOffset : (inout CGPoint *)targetContentOffset {
509
- if (!_overdrag) {
510
- if (_currentIndex == 0 && scrollView.contentOffset .x <= scrollView.bounds .size .width ) {
511
- *targetContentOffset = CGPointMake (scrollView.bounds .size .width , 0 );
512
- } else if (_currentIndex == _reactPageIndicatorView.numberOfPages -1 && scrollView.contentOffset .x >= scrollView.bounds .size .width ) {
513
- *targetContentOffset = CGPointMake (scrollView.bounds .size .width , 0 );
514
- }
515
- }
516
508
[_eventDispatcher sendEvent: [[RCTOnPageScrollStateChanged alloc ] initWithReactTag: self .reactTag state: @" settling" coalescingKey: _coalescingKey++]];
517
509
}
518
510
@@ -521,14 +513,6 @@ - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
521
513
}
522
514
523
515
- (void )scrollViewDidScroll : (UIScrollView *)scrollView {
524
- if (!_overdrag) {
525
- if (_currentIndex == 0 && scrollView.contentOffset .x < scrollView.bounds .size .width ) {
526
- scrollView.contentOffset = CGPointMake (scrollView.bounds .size .width , 0 );
527
- } else if (_currentIndex == _reactPageIndicatorView.numberOfPages -1 && scrollView.contentOffset .x > scrollView.bounds .size .width ) {
528
- scrollView.contentOffset = CGPointMake (scrollView.bounds .size .width , 0 );
529
- }
530
- }
531
-
532
516
CGPoint point = scrollView.contentOffset ;
533
517
float offset = (point.x - self.frame .size .width )/self.frame .size .width ;
534
518
if (fabs (offset) > 1 ) {
0 commit comments