@rific/scroll-view 0.7.0 → 0.7.1
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/dist/index.js +11 -0
- package/dist/index.mjs +14 -3
- package/package.json +1 -1
- package/src/ScrollViewProvider.tsx +20 -1
package/dist/index.js
CHANGED
|
@@ -1258,6 +1258,17 @@ var ScrollViewProvider = ({ blur, children, fixed = false, footerAboveKeyboard =
|
|
|
1258
1258
|
}, 3e3);
|
|
1259
1259
|
return () => clearTimeout(timeout);
|
|
1260
1260
|
}, [headerHeight]);
|
|
1261
|
+
(0, import_react15.useEffect)(() => {
|
|
1262
|
+
if (import_react_native13.Platform.OS !== "web" || headerHeight !== null) return;
|
|
1263
|
+
let raf2 = 0;
|
|
1264
|
+
const raf1 = requestAnimationFrame(() => {
|
|
1265
|
+
raf2 = requestAnimationFrame(() => setHeaderHeight(0));
|
|
1266
|
+
});
|
|
1267
|
+
return () => {
|
|
1268
|
+
cancelAnimationFrame(raf1);
|
|
1269
|
+
cancelAnimationFrame(raf2);
|
|
1270
|
+
};
|
|
1271
|
+
}, [headerHeight, setHeaderHeight]);
|
|
1261
1272
|
const setFooterHeight = (0, import_react15.useCallback)(
|
|
1262
1273
|
(h) => {
|
|
1263
1274
|
if (h === 0 && footerHeight) return;
|
package/dist/index.mjs
CHANGED
|
@@ -1158,7 +1158,7 @@ var styles7 = StyleSheet6.create({
|
|
|
1158
1158
|
// src/ScrollViewProvider.tsx
|
|
1159
1159
|
import { useBlur } from "@rific/auto-paper";
|
|
1160
1160
|
import { useCallback as useCallback7, useContext as useContext12, useEffect as useEffect5, useMemo as useMemo5, useRef as useRef8, useState as useState5 } from "react";
|
|
1161
|
-
import { Dimensions as Dimensions3 } from "react-native";
|
|
1161
|
+
import { Dimensions as Dimensions3, Platform as Platform5 } from "react-native";
|
|
1162
1162
|
import { useSharedValue as useSharedValue7 } from "react-native-reanimated";
|
|
1163
1163
|
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
1164
1164
|
var ScrollViewProvider = ({ blur, children, fixed = false, footerAboveKeyboard = false, footerFixed, headerFixed, snapBack, snapBackFooter, snapBackHeader, tabBarHeight = 0 }) => {
|
|
@@ -1206,6 +1206,17 @@ var ScrollViewProvider = ({ blur, children, fixed = false, footerAboveKeyboard =
|
|
|
1206
1206
|
}, 3e3);
|
|
1207
1207
|
return () => clearTimeout(timeout);
|
|
1208
1208
|
}, [headerHeight]);
|
|
1209
|
+
useEffect5(() => {
|
|
1210
|
+
if (Platform5.OS !== "web" || headerHeight !== null) return;
|
|
1211
|
+
let raf2 = 0;
|
|
1212
|
+
const raf1 = requestAnimationFrame(() => {
|
|
1213
|
+
raf2 = requestAnimationFrame(() => setHeaderHeight(0));
|
|
1214
|
+
});
|
|
1215
|
+
return () => {
|
|
1216
|
+
cancelAnimationFrame(raf1);
|
|
1217
|
+
cancelAnimationFrame(raf2);
|
|
1218
|
+
};
|
|
1219
|
+
}, [headerHeight, setHeaderHeight]);
|
|
1209
1220
|
const setFooterHeight = useCallback7(
|
|
1210
1221
|
(h) => {
|
|
1211
1222
|
if (h === 0 && footerHeight) return;
|
|
@@ -1245,7 +1256,7 @@ var ScrollViewSettingsProvider = ({ children, onChange, initialValue }) => {
|
|
|
1245
1256
|
|
|
1246
1257
|
// src/SectionList.tsx
|
|
1247
1258
|
import { memo as memo4, useCallback as useCallback10, useContext as useContext14, useEffect as useEffect6, useLayoutEffect as useLayoutEffect6, useMemo as useMemo7, useRef as useRef10 } from "react";
|
|
1248
|
-
import { Dimensions as Dimensions4, Platform as
|
|
1259
|
+
import { Dimensions as Dimensions4, Platform as Platform6, SectionList as RNSectionList, View as View7 } from "react-native";
|
|
1249
1260
|
import { Gesture as Gesture4, GestureDetector as GestureDetector4 } from "react-native-gesture-handler";
|
|
1250
1261
|
import Animated7, { runOnUI as runOnUI3, useSharedValue as useSharedValue9 } from "react-native-reanimated";
|
|
1251
1262
|
|
|
@@ -1374,7 +1385,7 @@ var SectionListInner = ({ chipProps, chipThreshold, contentContainerStyle: exter
|
|
|
1374
1385
|
const capturedGeneration = useSharedValue9(-1);
|
|
1375
1386
|
useLayoutEffect6(() => {
|
|
1376
1387
|
const generation = listGeneration.value;
|
|
1377
|
-
if (
|
|
1388
|
+
if (Platform6.OS === "web") {
|
|
1378
1389
|
capturedGeneration.value = generation;
|
|
1379
1390
|
return;
|
|
1380
1391
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useBlur } from '@rific/auto-paper'
|
|
2
2
|
import { type ReactNode, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react'
|
|
3
|
-
import { Dimensions } from 'react-native'
|
|
3
|
+
import { Dimensions, Platform } from 'react-native'
|
|
4
4
|
import { useSharedValue } from 'react-native-reanimated'
|
|
5
5
|
|
|
6
6
|
import { ScrollViewContext } from './ScrollViewContext'
|
|
@@ -70,6 +70,25 @@ export const ScrollViewProvider = ({ blur, children, fixed = false, footerAboveK
|
|
|
70
70
|
}, 3000)
|
|
71
71
|
return () => clearTimeout(timeout)
|
|
72
72
|
}, [headerHeight])
|
|
73
|
+
// Web-only recovery for a real race: a header's ResizeObserver-backed onLayout can simply never
|
|
74
|
+
// fire on the very first mount through Expo Router (observed in practice, not just theorized —
|
|
75
|
+
// content stuck at opacity: 0 indefinitely, with no error, only escaping via an unrelated resize
|
|
76
|
+
// forcing a fresh layout pass). Native RN doesn't have this race — onLayout is reliable there, and
|
|
77
|
+
// a persistently-null headerHeight really does mean "no header was ever rendered," which the
|
|
78
|
+
// warning above should keep flagging. On web, give a real first layout two frames to arrive before
|
|
79
|
+
// assuming there isn't one; setHeaderHeight(0) is exactly what a genuinely header-less screen would
|
|
80
|
+
// report anyway, so this is indistinguishable from that case once it fires.
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
if (Platform.OS !== 'web' || headerHeight !== null) return
|
|
83
|
+
let raf2 = 0
|
|
84
|
+
const raf1 = requestAnimationFrame(() => {
|
|
85
|
+
raf2 = requestAnimationFrame(() => setHeaderHeight(0))
|
|
86
|
+
})
|
|
87
|
+
return () => {
|
|
88
|
+
cancelAnimationFrame(raf1)
|
|
89
|
+
cancelAnimationFrame(raf2)
|
|
90
|
+
}
|
|
91
|
+
}, [headerHeight, setHeaderHeight])
|
|
73
92
|
const setFooterHeight = useCallback(
|
|
74
93
|
(h: number | null) => {
|
|
75
94
|
// Same race setHeaderHeight guards against, on the footer side: react-native-screens' web
|