@onekeyfe/react-native-pager-view 3.0.141 → 3.0.144

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -67,5 +67,11 @@ Web scroll child can opt in by exposing a DOM element with
67
67
  `data-collapsible-pager-scroll`. CSS scroll timelines drive header/sticky
68
68
  movement, so React is not updated on each vertical scroll frame.
69
69
 
70
+ On iOS and Android, `nativeTabBar` renders the tab bar natively and
71
+ `onNativeTabPress` reports presses. A press animates to the pressed page by
72
+ default. Set `nativeTabPressAnimationEnabled={false}` to jump straight there,
73
+ so pressing a distant tab does not scroll through every page in between,
74
+ including unmounted pages that would show blank.
75
+
70
76
  Thank you again to Callstack and everyone who contributes to
71
77
  `react-native-pager-view` 💙
@@ -166,7 +166,7 @@ export class CollapsiblePagerView extends React.PureComponent {
166
166
  onNativeTabPress = event => {
167
167
  const position = pageIndex(event.nativeEvent.position);
168
168
  if (position !== null && position >= 0 && position < this.pages().length && (position !== this.state.selectedPage || this.latestNativeTabTarget !== null)) {
169
- this.dispatchNativeTabPageCommand(position, true);
169
+ this.dispatchNativeTabPageCommand(position, this.props.nativeTabPressAnimationEnabled ?? true);
170
170
  }
171
171
  this.props.onNativeTabPress?.(event);
172
172
  };
@@ -187,6 +187,7 @@ export class CollapsiblePagerView extends React.PureComponent {
187
187
  onPageScrollStateChanged: _onPageScrollStateChanged,
188
188
  nativeTabBar,
189
189
  onNativeTabPress: _onNativeTabPress,
190
+ nativeTabPressAnimationEnabled: _nativeTabPressAnimationEnabled,
190
191
  nativeSubHeader,
191
192
  onNativeSubHeaderPress: _onNativeSubHeaderPress,
192
193
  layoutDirection,
@@ -79,6 +79,12 @@ export interface CollapsiblePagerViewProps extends Omit<NativeProps, "children"
79
79
  /** Optional native tab bar for iOS and Android. */
80
80
  nativeTabBar?: CollapsiblePagerNativeTabBarConfig;
81
81
  onNativeTabPress?: (event: CollapsiblePagerViewOnNativeTabPressEvent) => void;
82
+ /**
83
+ * Animates the page change started by a native tab press. Defaults to true.
84
+ * Set false to jump straight to the pressed page, so a distant tab does not
85
+ * scroll through every page in between, including unmounted ones.
86
+ */
87
+ nativeTabPressAnimationEnabled?: boolean;
82
88
  /** Optional native secondary sticky header for iOS and Android. */
83
89
  nativeSubHeader?: CollapsiblePagerNativeSubHeaderConfig;
84
90
  onNativeSubHeaderPress?: (event: CollapsiblePagerViewOnNativeSubHeaderPressEvent) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-pager-view",
3
- "version": "3.0.141",
3
+ "version": "3.0.144",
4
4
  "description": "React Native wrapper for Android and iOS ViewPager",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/module/index.js",
@@ -66,7 +66,7 @@
66
66
  "typescript": "^5.9.2"
67
67
  },
68
68
  "peerDependencies": {
69
- "@onekeyfe/react-native-native-logger": "3.0.141",
69
+ "@onekeyfe/react-native-native-logger": "3.0.144",
70
70
  "react": "*",
71
71
  "react-native": "*"
72
72
  },
@@ -129,6 +129,12 @@ export interface CollapsiblePagerViewProps
129
129
  /** Optional native tab bar for iOS and Android. */
130
130
  nativeTabBar?: CollapsiblePagerNativeTabBarConfig;
131
131
  onNativeTabPress?: (event: CollapsiblePagerViewOnNativeTabPressEvent) => void;
132
+ /**
133
+ * Animates the page change started by a native tab press. Defaults to true.
134
+ * Set false to jump straight to the pressed page, so a distant tab does not
135
+ * scroll through every page in between, including unmounted ones.
136
+ */
137
+ nativeTabPressAnimationEnabled?: boolean;
132
138
  /** Optional native secondary sticky header for iOS and Android. */
133
139
  nativeSubHeader?: CollapsiblePagerNativeSubHeaderConfig;
134
140
  onNativeSubHeaderPress?: (
@@ -403,7 +409,10 @@ export class CollapsiblePagerView extends React.PureComponent<
403
409
  (position !== this.state.selectedPage ||
404
410
  this.latestNativeTabTarget !== null)
405
411
  ) {
406
- this.dispatchNativeTabPageCommand(position, true);
412
+ this.dispatchNativeTabPageCommand(
413
+ position,
414
+ this.props.nativeTabPressAnimationEnabled ?? true
415
+ );
407
416
  }
408
417
  this.props.onNativeTabPress?.(event);
409
418
  };
@@ -428,6 +437,7 @@ export class CollapsiblePagerView extends React.PureComponent<
428
437
  onPageScrollStateChanged: _onPageScrollStateChanged,
429
438
  nativeTabBar,
430
439
  onNativeTabPress: _onNativeTabPress,
440
+ nativeTabPressAnimationEnabled: _nativeTabPressAnimationEnabled,
431
441
  nativeSubHeader,
432
442
  onNativeSubHeaderPress: _onNativeSubHeaderPress,
433
443
  layoutDirection,