@rific/drawer 0.7.0 → 0.7.2
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 +2 -2
- package/dist/index.js +12 -6
- package/dist/index.mjs +12 -6
- package/package.json +10 -10
- package/src/Drawer.tsx +45 -8
package/README.md
CHANGED
|
@@ -203,7 +203,7 @@ const MenuDrawer = ({ open, onOpen, onClose }: MenuDrawerProps) => {
|
|
|
203
203
|
}
|
|
204
204
|
```
|
|
205
205
|
|
|
206
|
-
The seed only matters for the very first frame: after that, `Drawer`
|
|
206
|
+
The seed only matters for the very first frame: after that, `Drawer` keeps the value at its own closed offset whenever that changes (rotation, a resize across the cap). While closed it jumps there rather than springing, so a panel that just grew never peeks in past the edge while it catches up.
|
|
207
207
|
|
|
208
208
|
If you're driving `Drawer` standalone with `contentSize` and want `DrawerEdgeSwipe`'s own commit-threshold math to track the measured size too, pass `Drawer` an `onMeasure?: (size: number) => void` and feed the result into the `height`/`width` you pass `DrawerEdgeSwipe`: this is exactly what `createDrawer()` does internally.
|
|
209
209
|
|
|
@@ -211,6 +211,6 @@ Both also take `maxHeight`/`maxWidth` (see [Expandable sheets](#expandable-sheet
|
|
|
211
211
|
|
|
212
212
|
`DrawerEdgeSwipe` alone also takes `insetTop`/`insetBottom`/`insetLeft`/`insetRight` (all default `0`), which shrink the edge-swipe hitbox's span along its long axis - only the pair perpendicular to `side`'s own strip thickness applies: `insetTop`/`insetBottom` for a `left`/`right` drawer's vertical strip, `insetLeft`/`insetRight` for a `top`/`bottom` drawer's horizontal one; the other pair is ignored. Use these to carve out chrome near the edge - a header or tab bar - that would otherwise have its own taps stolen by a hitbox spanning the full screen. Don't confuse this with `edgeInset` (see [Safe area](#safe-area)): that shrinks the *basis* a percentage size resolves against, on both `Drawer` and `DrawerEdgeSwipe`; these inset props only trim `DrawerEdgeSwipe`'s own hitbox span and have no equivalent on `Drawer` or `createDrawer()`.
|
|
213
213
|
|
|
214
|
-
`Drawer` also takes an `onClosed?: () => void`, fired once the close spring actually settles rather than the instant `open` flips to `false
|
|
214
|
+
`Drawer` also takes an `onClosed?: () => void`, fired once the close spring actually settles rather than the instant `open` flips to `false` (and again whenever a resize moves an already-closed panel to its new closed offset): this is what powers `isVisible` above; drive it yourself the same way if you're managing `open` state by hand. `onOpened?: () => void` is the same idea for the open direction: fired once the panel has actually finished sliding in, e.g. to autofocus a field inside `content` only once it's actually on screen. `createDrawer()` doesn't need it internally (nothing downstream waits on the open side settling the way `isVisible` waits on the close side), so it's only available driving `Drawer` directly.
|
|
215
215
|
|
|
216
216
|
`Drawer` also takes the same `zIndex` prop described in [Stacking multiple drawers](#stacking-multiple-drawers), useful if you're rendering more than one standalone `Drawer` (or mixing standalone `Drawer`s with `createDrawer()` ones) that might be open at the same time.
|
package/dist/index.js
CHANGED
|
@@ -117,13 +117,21 @@ var Drawer = ({ backdropOpacity = 0.45, blockingBackdrop = true, blur, children,
|
|
|
117
117
|
const { autoPaper } = getDrawerConfig();
|
|
118
118
|
const resolvedBlur = (autoPaper?.useBlur ?? useBlurFallback)(blur);
|
|
119
119
|
const animatedSize = (0, import_react_native_reanimated.useSharedValue)(effectiveSize);
|
|
120
|
+
const lastOpenRef = (0, import_react.useRef)(null);
|
|
120
121
|
(0, import_react.useEffect)(() => {
|
|
122
|
+
const openChanged = lastOpenRef.current !== open;
|
|
123
|
+
lastOpenRef.current = open;
|
|
121
124
|
if (open) {
|
|
122
125
|
translateOffset.value = (0, import_react_native_reanimated.withSpring)(restOffset, SPRING, (finished) => {
|
|
123
126
|
if (finished && onOpened) (0, import_react_native_reanimated.runOnJS)(onOpened)();
|
|
124
127
|
});
|
|
125
128
|
return;
|
|
126
129
|
}
|
|
130
|
+
if (!openChanged) {
|
|
131
|
+
translateOffset.value = closedOffset;
|
|
132
|
+
onClosed?.();
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
127
135
|
translateOffset.value = (0, import_react_native_reanimated.withSpring)(closedOffset, SPRING, (finished) => {
|
|
128
136
|
if (finished && onClosed) (0, import_react_native_reanimated.runOnJS)(onClosed)();
|
|
129
137
|
});
|
|
@@ -148,6 +156,7 @@ var Drawer = ({ backdropOpacity = 0.45, blockingBackdrop = true, blur, children,
|
|
|
148
156
|
onMeasure?.(measured);
|
|
149
157
|
};
|
|
150
158
|
const fillStyle = import_react_native2.StyleSheet.absoluteFill;
|
|
159
|
+
const clipOverflowStyle = { overflow: import_react_native2.Platform.OS === "web" ? "clip" : "hidden" };
|
|
151
160
|
const fill = resolvedBlur && autoPaper ? contentSize ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
152
161
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(autoPaper.BlurView, { style: fillStyle }),
|
|
153
162
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { onLayout: handleLayout, children })
|
|
@@ -156,7 +165,7 @@ var Drawer = ({ backdropOpacity = 0.45, blockingBackdrop = true, blur, children,
|
|
|
156
165
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { onLayout: handleLayout, children })
|
|
157
166
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: [fillStyle, { backgroundColor: colors.surface }], children });
|
|
158
167
|
const drawerOuterStyle = contentSize ? [styles.drawer, positionStyle, drawerStyle, animatedSizeStyle, { zIndex: zIndex + 1 }] : [styles.drawer, positionStyle, sizeStyle, drawerStyle, { zIndex: zIndex + 1 }];
|
|
159
|
-
const contentClipStyle = [fillStyle,
|
|
168
|
+
const contentClipStyle = [fillStyle, clipOverflowStyle, { flexDirection: vertical ? "column" : "row" }];
|
|
160
169
|
const clampMin = Math.min(0, closedOffset);
|
|
161
170
|
const clampMax = Math.max(0, closedOffset);
|
|
162
171
|
const handleAxisGesture = vertical ? import_react_native_gesture_handler.Gesture.Pan().activeOffsetY(restOffset !== 0 ? [-10, 10] : closeDirection * 10).failOffsetX([-15, 15]) : import_react_native_gesture_handler.Gesture.Pan().activeOffsetX(restOffset !== 0 ? [-10, 10] : closeDirection * 10).failOffsetY([-15, 15]);
|
|
@@ -214,7 +223,7 @@ var Drawer = ({ backdropOpacity = 0.45, blockingBackdrop = true, blur, children,
|
|
|
214
223
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native_reanimated.default.View, { style: [styles.backdropTint, backdropStyle], pointerEvents: "none" }),
|
|
215
224
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native_gesture_handler.GestureDetector, { gesture: backdropTapGesture, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native_reanimated.default.View, { collapsable: false, style: [import_react_native2.StyleSheet.absoluteFill, backdropTapAreaStyle] }) })
|
|
216
225
|
] }),
|
|
217
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { pointerEvents: "box-none", style: [styles.panelClip, { zIndex: zIndex + 1 }], children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native_reanimated.default.View, { style: drawerOuterStyle, children: [
|
|
226
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { pointerEvents: "box-none", style: [styles.panelClip, clipOverflowStyle, { zIndex: zIndex + 1 }], children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native_reanimated.default.View, { style: drawerOuterStyle, children: [
|
|
218
227
|
resolvedPanelShadow && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native_reanimated.default.View, { pointerEvents: "none", style: [import_react_native2.StyleSheet.absoluteFill, panelShadowStyle, panelShadowVisibilityStyle] }),
|
|
219
228
|
contentSize ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: contentClipStyle, children: fill }) : fill,
|
|
220
229
|
dismissible && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native_gesture_handler.GestureDetector, { gesture: handleGesture, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native_reanimated.default.View, { style: [styles.handleStrip, handleStripSizeStyle, handleStripEdgeStyle, handleStripPaddingStyle, webCursorStyle2, handleVisibilityStyle, handleStripInteractionStyle], children: showHandle && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: [styles.handlePill, handlePillStyle, { backgroundColor: colors.surface }] }) }) })
|
|
@@ -257,9 +266,6 @@ var styles = import_react_native2.StyleSheet.create({
|
|
|
257
266
|
right: 0,
|
|
258
267
|
top: 0
|
|
259
268
|
},
|
|
260
|
-
clip: {
|
|
261
|
-
overflow: "hidden"
|
|
262
|
-
},
|
|
263
269
|
drawer: {
|
|
264
270
|
position: "absolute"
|
|
265
271
|
},
|
|
@@ -273,10 +279,10 @@ var styles = import_react_native2.StyleSheet.create({
|
|
|
273
279
|
},
|
|
274
280
|
// See the comment above <View style={styles.panelClip}> in the render - the unconditional clip
|
|
275
281
|
// ancestor that keeps a translated-off-screen "closed" panel from inflating page scroll extent.
|
|
282
|
+
// Its overflow comes from clipOverflowStyle in the render, since it differs per platform.
|
|
276
283
|
panelClip: {
|
|
277
284
|
bottom: 0,
|
|
278
285
|
left: 0,
|
|
279
|
-
overflow: "hidden",
|
|
280
286
|
position: "absolute",
|
|
281
287
|
right: 0,
|
|
282
288
|
top: 0
|
package/dist/index.mjs
CHANGED
|
@@ -74,13 +74,21 @@ var Drawer = ({ backdropOpacity = 0.45, blockingBackdrop = true, blur, children,
|
|
|
74
74
|
const { autoPaper } = getDrawerConfig();
|
|
75
75
|
const resolvedBlur = (autoPaper?.useBlur ?? useBlurFallback)(blur);
|
|
76
76
|
const animatedSize = useSharedValue(effectiveSize);
|
|
77
|
+
const lastOpenRef = useRef(null);
|
|
77
78
|
useEffect(() => {
|
|
79
|
+
const openChanged = lastOpenRef.current !== open;
|
|
80
|
+
lastOpenRef.current = open;
|
|
78
81
|
if (open) {
|
|
79
82
|
translateOffset.value = withSpring(restOffset, SPRING, (finished) => {
|
|
80
83
|
if (finished && onOpened) runOnJS(onOpened)();
|
|
81
84
|
});
|
|
82
85
|
return;
|
|
83
86
|
}
|
|
87
|
+
if (!openChanged) {
|
|
88
|
+
translateOffset.value = closedOffset;
|
|
89
|
+
onClosed?.();
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
84
92
|
translateOffset.value = withSpring(closedOffset, SPRING, (finished) => {
|
|
85
93
|
if (finished && onClosed) runOnJS(onClosed)();
|
|
86
94
|
});
|
|
@@ -105,6 +113,7 @@ var Drawer = ({ backdropOpacity = 0.45, blockingBackdrop = true, blur, children,
|
|
|
105
113
|
onMeasure?.(measured);
|
|
106
114
|
};
|
|
107
115
|
const fillStyle = StyleSheet.absoluteFill;
|
|
116
|
+
const clipOverflowStyle = { overflow: Platform.OS === "web" ? "clip" : "hidden" };
|
|
108
117
|
const fill = resolvedBlur && autoPaper ? contentSize ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
109
118
|
/* @__PURE__ */ jsx(autoPaper.BlurView, { style: fillStyle }),
|
|
110
119
|
/* @__PURE__ */ jsx(View, { onLayout: handleLayout, children })
|
|
@@ -113,7 +122,7 @@ var Drawer = ({ backdropOpacity = 0.45, blockingBackdrop = true, blur, children,
|
|
|
113
122
|
/* @__PURE__ */ jsx(View, { onLayout: handleLayout, children })
|
|
114
123
|
] }) : /* @__PURE__ */ jsx(View, { style: [fillStyle, { backgroundColor: colors.surface }], children });
|
|
115
124
|
const drawerOuterStyle = contentSize ? [styles.drawer, positionStyle, drawerStyle, animatedSizeStyle, { zIndex: zIndex + 1 }] : [styles.drawer, positionStyle, sizeStyle, drawerStyle, { zIndex: zIndex + 1 }];
|
|
116
|
-
const contentClipStyle = [fillStyle,
|
|
125
|
+
const contentClipStyle = [fillStyle, clipOverflowStyle, { flexDirection: vertical ? "column" : "row" }];
|
|
117
126
|
const clampMin = Math.min(0, closedOffset);
|
|
118
127
|
const clampMax = Math.max(0, closedOffset);
|
|
119
128
|
const handleAxisGesture = vertical ? Gesture.Pan().activeOffsetY(restOffset !== 0 ? [-10, 10] : closeDirection * 10).failOffsetX([-15, 15]) : Gesture.Pan().activeOffsetX(restOffset !== 0 ? [-10, 10] : closeDirection * 10).failOffsetY([-15, 15]);
|
|
@@ -171,7 +180,7 @@ var Drawer = ({ backdropOpacity = 0.45, blockingBackdrop = true, blur, children,
|
|
|
171
180
|
/* @__PURE__ */ jsx(Animated.View, { style: [styles.backdropTint, backdropStyle], pointerEvents: "none" }),
|
|
172
181
|
/* @__PURE__ */ jsx(GestureDetector, { gesture: backdropTapGesture, children: /* @__PURE__ */ jsx(Animated.View, { collapsable: false, style: [StyleSheet.absoluteFill, backdropTapAreaStyle] }) })
|
|
173
182
|
] }),
|
|
174
|
-
/* @__PURE__ */ jsx(View, { pointerEvents: "box-none", style: [styles.panelClip, { zIndex: zIndex + 1 }], children: /* @__PURE__ */ jsxs(Animated.View, { style: drawerOuterStyle, children: [
|
|
183
|
+
/* @__PURE__ */ jsx(View, { pointerEvents: "box-none", style: [styles.panelClip, clipOverflowStyle, { zIndex: zIndex + 1 }], children: /* @__PURE__ */ jsxs(Animated.View, { style: drawerOuterStyle, children: [
|
|
175
184
|
resolvedPanelShadow && /* @__PURE__ */ jsx(Animated.View, { pointerEvents: "none", style: [StyleSheet.absoluteFill, panelShadowStyle, panelShadowVisibilityStyle] }),
|
|
176
185
|
contentSize ? /* @__PURE__ */ jsx(View, { style: contentClipStyle, children: fill }) : fill,
|
|
177
186
|
dismissible && /* @__PURE__ */ jsx(GestureDetector, { gesture: handleGesture, children: /* @__PURE__ */ jsx(Animated.View, { style: [styles.handleStrip, handleStripSizeStyle, handleStripEdgeStyle, handleStripPaddingStyle, webCursorStyle2, handleVisibilityStyle, handleStripInteractionStyle], children: showHandle && /* @__PURE__ */ jsx(View, { style: [styles.handlePill, handlePillStyle, { backgroundColor: colors.surface }] }) }) })
|
|
@@ -214,9 +223,6 @@ var styles = StyleSheet.create({
|
|
|
214
223
|
right: 0,
|
|
215
224
|
top: 0
|
|
216
225
|
},
|
|
217
|
-
clip: {
|
|
218
|
-
overflow: "hidden"
|
|
219
|
-
},
|
|
220
226
|
drawer: {
|
|
221
227
|
position: "absolute"
|
|
222
228
|
},
|
|
@@ -230,10 +236,10 @@ var styles = StyleSheet.create({
|
|
|
230
236
|
},
|
|
231
237
|
// See the comment above <View style={styles.panelClip}> in the render - the unconditional clip
|
|
232
238
|
// ancestor that keeps a translated-off-screen "closed" panel from inflating page scroll extent.
|
|
239
|
+
// Its overflow comes from clipOverflowStyle in the render, since it differs per platform.
|
|
233
240
|
panelClip: {
|
|
234
241
|
bottom: 0,
|
|
235
242
|
left: 0,
|
|
236
|
-
overflow: "hidden",
|
|
237
243
|
position: "absolute",
|
|
238
244
|
right: 0,
|
|
239
245
|
top: 0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rific/drawer",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "Left/right sliding drawer with edge-swipe gestures for React Native: spring-animated, theme-aware, one factory call per drawer instance",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
@@ -63,10 +63,10 @@
|
|
|
63
63
|
"prettier": "@infinitetoken/eslint-config/prettier",
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@infinitetoken/eslint-config": "0.2.0",
|
|
66
|
-
"@infinitetoken/jest-config": "^0.
|
|
67
|
-
"@infinitetoken/tsconfig": "^0.
|
|
68
|
-
"@rific/auto-paper": "^0.
|
|
69
|
-
"@rific/core": "^0.
|
|
66
|
+
"@infinitetoken/jest-config": "^0.5.1",
|
|
67
|
+
"@infinitetoken/tsconfig": "^0.6.0",
|
|
68
|
+
"@rific/auto-paper": "^0.13.3",
|
|
69
|
+
"@rific/core": "^0.3.1",
|
|
70
70
|
"@testing-library/dom": "^10.4.1",
|
|
71
71
|
"@testing-library/react": "^16.3.2",
|
|
72
72
|
"@types/jest": "^30.0.0",
|
|
@@ -79,12 +79,12 @@
|
|
|
79
79
|
"prettier": "^3.8.3",
|
|
80
80
|
"react": "^19.0.0",
|
|
81
81
|
"react-dom": "^19.0.0",
|
|
82
|
-
"react-native": "^0.
|
|
83
|
-
"react-native-gesture-handler": "^
|
|
82
|
+
"react-native": "^0.88.0",
|
|
83
|
+
"react-native-gesture-handler": "^3.3.0",
|
|
84
84
|
"react-native-paper": "^5.12.0",
|
|
85
|
-
"react-native-reanimated": "^4.
|
|
85
|
+
"react-native-reanimated": "^4.7.1",
|
|
86
86
|
"react-native-safe-area-context": "^5.5.2",
|
|
87
|
-
"react-native-worklets": "^0.
|
|
87
|
+
"react-native-worklets": "^0.13.0",
|
|
88
88
|
"tsup": "^8.0.0",
|
|
89
89
|
"typescript": "^6.0.3"
|
|
90
90
|
},
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"@rific/core": ">=0.1.1",
|
|
94
94
|
"react": ">=19.0.0",
|
|
95
95
|
"react-native": ">=0.83.0",
|
|
96
|
-
"react-native-gesture-handler": ">=2.20.0 <
|
|
96
|
+
"react-native-gesture-handler": ">=2.20.0 <4.0.0",
|
|
97
97
|
"react-native-paper": ">=5.0.0",
|
|
98
98
|
"react-native-reanimated": ">=4.0.0"
|
|
99
99
|
},
|
package/src/Drawer.tsx
CHANGED
|
@@ -176,7 +176,17 @@ export const Drawer = ({ backdropOpacity = 0.45, blockingBackdrop = true, blur,
|
|
|
176
176
|
// useAnimatedStyle, so it only restarts its transition when effectiveSize actually changes.
|
|
177
177
|
const animatedSize = useSharedValue(effectiveSize)
|
|
178
178
|
|
|
179
|
+
// The `open` the effect below last ran for, so it can tell a real open/close (which springs) from
|
|
180
|
+
// the geometry changing under a closed panel (which jumps, see below). null until the first run,
|
|
181
|
+
// so mounting counts as a change and springs exactly as before.
|
|
182
|
+
const lastOpenRef = useRef<boolean | null>(null)
|
|
183
|
+
|
|
184
|
+
// react-hooks/immutability misreads the translateOffset.value writes here (a Reanimated
|
|
185
|
+
// SharedValue, not a prop reassignment) once this effect also writes lastOpenRef.
|
|
186
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
179
187
|
useEffect(() => {
|
|
188
|
+
const openChanged = lastOpenRef.current !== open
|
|
189
|
+
lastOpenRef.current = open
|
|
180
190
|
if (open) {
|
|
181
191
|
// Rests at restOffset (== 0, fully expanded, when there's no maxHeight/maxWidth - identical
|
|
182
192
|
// to before), not always 0: an expandable sheet opens to its rest size, not its max size.
|
|
@@ -185,6 +195,17 @@ export const Drawer = ({ backdropOpacity = 0.45, blockingBackdrop = true, blur,
|
|
|
185
195
|
})
|
|
186
196
|
return
|
|
187
197
|
}
|
|
198
|
+
if (!openChanged) {
|
|
199
|
+
// Still closed, but closedOffset moved (the window resized, or contentSize re-measured): jump
|
|
200
|
+
// to it rather than spring. The panel's box takes its new size at once, so springing a grown
|
|
201
|
+
// panel out from its old, smaller offset left the difference peeking in past the screen edge
|
|
202
|
+
// for the whole spring (15px of a closed window-wide drawer when the window went 360 to 375).
|
|
203
|
+
// A jump also cancels a close spring still in flight, whose callback then reports unfinished,
|
|
204
|
+
// so onClosed is called here instead (a resize while settled closed re-fired it before too).
|
|
205
|
+
translateOffset.value = closedOffset
|
|
206
|
+
onClosed?.()
|
|
207
|
+
return
|
|
208
|
+
}
|
|
188
209
|
translateOffset.value = withSpring(closedOffset, SPRING, (finished) => {
|
|
189
210
|
if (finished && onClosed) runOnJS(onClosed)()
|
|
190
211
|
})
|
|
@@ -280,6 +301,20 @@ export const Drawer = ({ backdropOpacity = 0.45, blockingBackdrop = true, blur,
|
|
|
280
301
|
// structure as a CSS accordion expand/collapse either way.
|
|
281
302
|
const fillStyle: StyleProp<ViewStyle> = StyleSheet.absoluteFill
|
|
282
303
|
|
|
304
|
+
// The overflow for both boxes here that exist only to clip (panelClip, and contentSize's clip
|
|
305
|
+
// wrapper below): 'clip' on web, 'hidden' on native. A web overflow:hidden box is still a scroll
|
|
306
|
+
// container: it hides the scrollbar, but scrollIntoView, focus and find-in-page can all still
|
|
307
|
+
// scroll it, and nothing ever scrolls it back. A full-window panel always leaves panelClip 28px of
|
|
308
|
+
// hidden overflow (the handle strip hangs HANDLE_STRIP_THICKNESS past the panel's far edge,
|
|
309
|
+
// off-screen), so a single centered scrollIntoView on a button inside the panel (browser
|
|
310
|
+
// automation clicking it, for one) scrolled panelClip by those 28px: the open panel sat 28px off
|
|
311
|
+
// its edge, its content cut off, with the screen underneath showing through on the far side.
|
|
312
|
+
// 'clip' paints the same clip but isn't a scroll container, so nothing can scroll it. Native views
|
|
313
|
+
// clip without ever scrolling, so 'hidden' (the only clip RN's own types allow, hence the cast)
|
|
314
|
+
// stays there. The value is computed directly, not left undefined on native: a later undefined
|
|
315
|
+
// overflow in a style array overrides an earlier 'hidden' once flattened.
|
|
316
|
+
const clipOverflowStyle = { overflow: Platform.OS === 'web' ? 'clip' : 'hidden' } as ViewStyle
|
|
317
|
+
|
|
283
318
|
const fill =
|
|
284
319
|
resolvedBlur && autoPaper ? (
|
|
285
320
|
contentSize ? (
|
|
@@ -318,9 +353,9 @@ export const Drawer = ({ backdropOpacity = 0.45, blockingBackdrop = true, blur,
|
|
|
318
353
|
// is checked structurally against Animated.View's own `style` prop below, whose type (reanimated's
|
|
319
354
|
// AnimatedStyle<ViewStyle>) already accounts for that handle.
|
|
320
355
|
const drawerOuterStyle = contentSize ? [styles.drawer, positionStyle, drawerStyle, animatedSizeStyle, { zIndex: zIndex + 1 }] : [styles.drawer, positionStyle, sizeStyle, drawerStyle, { zIndex: zIndex + 1 }]
|
|
321
|
-
// contentSize's clip (
|
|
356
|
+
// contentSize's clip (clipOverflowStyle) + flex axis, previously on drawerOuterStyle itself, now
|
|
322
357
|
// live on this inner wrapper instead, so the outer stays unclipped for the handle strip's sake.
|
|
323
|
-
const contentClipStyle: StyleProp<ViewStyle> = [fillStyle,
|
|
358
|
+
const contentClipStyle: StyleProp<ViewStyle> = [fillStyle, clipOverflowStyle, { flexDirection: vertical ? 'column' : 'row' }]
|
|
324
359
|
|
|
325
360
|
// Dismiss-and-expand handle: a strip pinned to the edge closest to the closed direction (the edge
|
|
326
361
|
// the panel slides back toward), gesture-matched to `side` the same way DrawerEdgeSwipe is. With no
|
|
@@ -373,6 +408,8 @@ export const Drawer = ({ backdropOpacity = 0.45, blockingBackdrop = true, blur,
|
|
|
373
408
|
.onUpdate((event) => {
|
|
374
409
|
'worklet'
|
|
375
410
|
const translation = vertical ? event.translationY : event.translationX
|
|
411
|
+
// Same SharedValue false positive as the open/close effect above (see its comment).
|
|
412
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
376
413
|
translateOffset.value = Math.min(clampMax, Math.max(clampMin, gestureStartOffset.value + translation))
|
|
377
414
|
})
|
|
378
415
|
.onEnd((event) => {
|
|
@@ -405,6 +442,8 @@ export const Drawer = ({ backdropOpacity = 0.45, blockingBackdrop = true, blur,
|
|
|
405
442
|
closing = progress > 1 / 3 || velocityD > VELOCITY_THRESHOLD
|
|
406
443
|
target = closing ? closedOffset : restOffset
|
|
407
444
|
}
|
|
445
|
+
// Same SharedValue false positive as the open/close effect above (see its comment).
|
|
446
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
408
447
|
translateOffset.value = withSpring(target, SPRING)
|
|
409
448
|
if (closing) runOnJS(onClose)()
|
|
410
449
|
})
|
|
@@ -522,8 +561,9 @@ export const Drawer = ({ backdropOpacity = 0.45, blockingBackdrop = true, blur,
|
|
|
522
561
|
z-index 0, which makes panelClip a stacking context of its own, so the panel's zIndex + 1
|
|
523
562
|
only ranks it inside panelClip. Without a tier here, the backdrop (zIndex, a sibling of
|
|
524
563
|
panelClip) painted over the whole panel, tint included, and an open drawer's own content
|
|
525
|
-
read as dimmed and disabled.
|
|
526
|
-
|
|
564
|
+
read as dimmed and disabled. Its overflow is clipOverflowStyle, never a plain 'hidden': see
|
|
565
|
+
that style's comment for how a web overflow:hidden box got scrolled off its edge. */}
|
|
566
|
+
<View pointerEvents='box-none' style={[styles.panelClip, clipOverflowStyle, { zIndex: zIndex + 1 }]}>
|
|
527
567
|
<Animated.View style={drawerOuterStyle}>
|
|
528
568
|
{/* pointerEvents='none': purely decorative, drawn outside the panel's own box (a directional
|
|
529
569
|
box-shadow never paints over the box's own content area), so it has no business
|
|
@@ -589,9 +629,6 @@ const styles = StyleSheet.create({
|
|
|
589
629
|
right: 0,
|
|
590
630
|
top: 0
|
|
591
631
|
},
|
|
592
|
-
clip: {
|
|
593
|
-
overflow: 'hidden'
|
|
594
|
-
},
|
|
595
632
|
drawer: {
|
|
596
633
|
position: 'absolute'
|
|
597
634
|
},
|
|
@@ -605,10 +642,10 @@ const styles = StyleSheet.create({
|
|
|
605
642
|
},
|
|
606
643
|
// See the comment above <View style={styles.panelClip}> in the render - the unconditional clip
|
|
607
644
|
// ancestor that keeps a translated-off-screen "closed" panel from inflating page scroll extent.
|
|
645
|
+
// Its overflow comes from clipOverflowStyle in the render, since it differs per platform.
|
|
608
646
|
panelClip: {
|
|
609
647
|
bottom: 0,
|
|
610
648
|
left: 0,
|
|
611
|
-
overflow: 'hidden',
|
|
612
649
|
position: 'absolute',
|
|
613
650
|
right: 0,
|
|
614
651
|
top: 0
|