diff --git a/example/src/App.tsx b/example/src/App.tsx
index f06807df..1e41a216 100644
--- a/example/src/App.tsx
+++ b/example/src/App.tsx
@@ -30,6 +30,7 @@ import TabBarIconExample from './tabView/TabBarIconExample';
import CustomIndicatorExample from './tabView/CustomIndicatorExample';
import CustomTabBarExample from './tabView/CustomTabBarExample';
import CoverflowExample from './tabView/CoverflowExample';
+import { TabViewInsideScrollViewExample } from './tabView/TabViewInsideScrollViewExample';
import ReanimatedOnPageScrollExample from './ReanimatedOnPageScrollExample';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { SafeAreaProvider } from 'react-native-safe-area-context';
@@ -47,6 +48,7 @@ const examples = [
component: ScrollablePagerViewExample,
name: 'Scrollable PagerView Example',
},
+ { component: TabViewInsideScrollViewExample, name: 'TabView inside ScrollView Example' },
{
component: ScrollViewInsideExample,
name: 'ScrollView inside PagerView Example',
diff --git a/example/src/tabView/TabViewInsideScrollViewExample.tsx b/example/src/tabView/TabViewInsideScrollViewExample.tsx
new file mode 100644
index 00000000..8d4d4357
--- /dev/null
+++ b/example/src/tabView/TabViewInsideScrollViewExample.tsx
@@ -0,0 +1,55 @@
+import * as React from 'react';
+import { View, useWindowDimensions, Text, ScrollView } from 'react-native';
+import { TabView, SceneMap } from 'react-native-tab-view';
+import { Header } from 'react-native/Libraries/NewAppScreen';
+
+function FirstRoute() {
+ return (
+
+ First Route
+
+ );
+}
+
+function SecondRoute() {
+ return (
+
+ Second Route
+
+ );
+}
+
+const renderScene = SceneMap({
+ first: FirstRoute,
+ second: SecondRoute,
+});
+
+const routes = [
+ { key: 'first', title: 'First' },
+ { key: 'second', title: 'Second' },
+];
+
+export function TabViewInsideScrollViewExample() {
+ const layout = useWindowDimensions();
+ const [index, setIndex] = React.useState(0);
+
+ return (
+
+
+
+
+
+
+
+ );
+}
\ No newline at end of file
diff --git a/ios/Fabric/RNCPagerViewComponentView.mm b/ios/Fabric/RNCPagerViewComponentView.mm
index 64de374f..2ea053b3 100644
--- a/ios/Fabric/RNCPagerViewComponentView.mm
+++ b/ios/Fabric/RNCPagerViewComponentView.mm
@@ -14,9 +14,7 @@
using namespace facebook::react;
-@interface RNCPagerViewComponentView ()
-
-@property(nonatomic, assign) UIPanGestureRecognizer* panGestureRecognizer;
+@interface RNCPagerViewComponentView ()
@end
@@ -71,11 +69,6 @@ - (instancetype)initWithFrame:(CGRect)frame
_destinationIndex = -1;
_layoutDirection = @"ltr";
_overdrag = NO;
- UIPanGestureRecognizer* panGestureRecognizer = [UIPanGestureRecognizer new];
- self.panGestureRecognizer = panGestureRecognizer;
- panGestureRecognizer.delegate = self;
- [self addGestureRecognizer: panGestureRecognizer];
-
}
return self;
@@ -409,30 +402,6 @@ + (ComponentDescriptorProvider)componentDescriptorProvider
return concreteComponentDescriptorProvider();
}
-
-- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
-
- // Recognize simultaneously only if the other gesture is RN Screen's pan gesture (one that is used to perform fullScreenGestureEnabled)
- if (gestureRecognizer == self.panGestureRecognizer && [NSStringFromClass([otherGestureRecognizer class]) isEqual: @"RNSPanGestureRecognizer"]) {
- UIPanGestureRecognizer* panGestureRecognizer = (UIPanGestureRecognizer*) gestureRecognizer;
- CGPoint velocity = [panGestureRecognizer velocityInView:self];
- BOOL isLTR = [self isLtrLayout];
- BOOL isBackGesture = (isLTR && velocity.x > 0) || (!isLTR && velocity.x < 0);
-
- if (self.currentIndex == 0 && isBackGesture) {
- scrollView.panGestureRecognizer.enabled = false;
- } else {
- const auto &viewProps = *std::static_pointer_cast(_props);
- scrollView.panGestureRecognizer.enabled = viewProps.scrollEnabled;
- }
-
- return YES;
- }
- const auto &viewProps = *std::static_pointer_cast(_props);
- scrollView.panGestureRecognizer.enabled = viewProps.scrollEnabled;
- return NO;
-}
-
@end
Class RNCViewPagerCls(void)
diff --git a/ios/RNCPagerView.m b/ios/RNCPagerView.m
index 7d99becc..2a5a3cef 100644
--- a/ios/RNCPagerView.m
+++ b/ios/RNCPagerView.m
@@ -8,9 +8,7 @@
#import "RCTOnPageSelected.h"
#import
-@interface RNCPagerView ()
-
-@property(nonatomic, assign) UIPanGestureRecognizer* panGestureRecognizer;
+@interface RNCPagerView ()
@property(nonatomic, strong) UIPageViewController *reactPageViewController;
@property(nonatomic, strong) RCTEventDispatcher *eventDispatcher;
@@ -48,10 +46,6 @@ - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher {
_cachedControllers = [NSHashTable hashTableWithOptions:NSHashTableStrongMemory];
_overdrag = NO;
_layoutDirection = @"ltr";
- UIPanGestureRecognizer* panGestureRecognizer = [UIPanGestureRecognizer new];
- self.panGestureRecognizer = panGestureRecognizer;
- panGestureRecognizer.delegate = self;
- [self addGestureRecognizer: panGestureRecognizer];
}
return self;
}
@@ -474,28 +468,6 @@ - (NSString *)determineScrollDirection:(UIScrollView *)scrollView {
return scrollDirection;
}
-- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
-
- // Recognize simultaneously only if the other gesture is RN Screen's pan gesture (one that is used to perform fullScreenGestureEnabled)
- if (gestureRecognizer == self.panGestureRecognizer && [NSStringFromClass([otherGestureRecognizer class]) isEqual: @"RNSPanGestureRecognizer"]) {
- UIPanGestureRecognizer* panGestureRecognizer = (UIPanGestureRecognizer*) gestureRecognizer;
- CGPoint velocity = [panGestureRecognizer velocityInView:self];
- BOOL isLTR = [self isLtrLayout];
- BOOL isBackGesture = (isLTR && velocity.x > 0) || (!isLTR && velocity.x < 0);
-
- if (self.currentIndex == 0 && isBackGesture) {
- self.scrollView.panGestureRecognizer.enabled = false;
- } else {
- self.scrollView.panGestureRecognizer.enabled = self.scrollEnabled;
- }
-
- return YES;
- }
-
- self.scrollView.panGestureRecognizer.enabled = self.scrollEnabled;
- return NO;
-}
-
- (BOOL)isLtrLayout {
return [_layoutDirection isEqualToString:@"ltr"];
}