@rific/drawer 0.4.5 → 0.5.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/README.md CHANGED
@@ -184,6 +184,8 @@ If you're driving `Drawer` standalone with `contentSize` and want `DrawerEdgeSwi
184
184
 
185
185
  Both also take `maxHeight`/`maxWidth` (see [Expandable sheets](#expandable-sheets)) — pass the same values to both, same as `height`/`width`, so `DrawerEdgeSwipe`'s edge-swipe-to-open lands at the same rest position `Drawer`'s own tap-to-open does. Same for `edgeInset` (see [Safe area](#safe-area)): pass the same value to both, or their rest/max geometry will disagree.
186
186
 
187
+ `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()`.
188
+
187
189
  `Drawer` also takes an `onClosed?: () => void`, fired once the close spring actually settles rather than the instant `open` flips to `false`: 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.
188
190
 
189
191
  `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.d.mts CHANGED
@@ -106,6 +106,10 @@ type DrawerEdgeSwipeProps = {
106
106
  edgeInset?: number;
107
107
  enabled?: boolean;
108
108
  height?: DrawerDimension;
109
+ insetBottom?: number;
110
+ insetLeft?: number;
111
+ insetRight?: number;
112
+ insetTop?: number;
109
113
  maxHeight?: DrawerDimension;
110
114
  maxWidth?: DrawerDimension;
111
115
  onOpen: () => void;
@@ -113,6 +117,6 @@ type DrawerEdgeSwipeProps = {
113
117
  translateOffset: SharedValue<number>;
114
118
  width?: DrawerDimension;
115
119
  };
116
- declare const DrawerEdgeSwipe: ({ edgeInset, enabled, height, maxHeight, maxWidth, onOpen, side, translateOffset, width }: DrawerEdgeSwipeProps) => react.JSX.Element;
120
+ declare const DrawerEdgeSwipe: ({ edgeInset, enabled, height, insetBottom, insetLeft, insetRight, insetTop, maxHeight, maxWidth, onOpen, side, translateOffset, width }: DrawerEdgeSwipeProps) => react.JSX.Element;
117
121
 
118
122
  export { type AutoPaperModule, type CreateDrawerOptions, type CreateDrawerResult, Drawer, type DrawerActions, type DrawerConfig, type DrawerDimension, DrawerEdgeSwipe, type DrawerEdgeSwipeProps, type DrawerInstanceProviderComponent, type DrawerInstanceProviderProps, type DrawerProps, DrawerProvider, type DrawerProviderProps, type DrawerSide, combineDrawerProviders, configureDrawer, createDrawer, getDrawerConfig };
package/dist/index.d.ts CHANGED
@@ -106,6 +106,10 @@ type DrawerEdgeSwipeProps = {
106
106
  edgeInset?: number;
107
107
  enabled?: boolean;
108
108
  height?: DrawerDimension;
109
+ insetBottom?: number;
110
+ insetLeft?: number;
111
+ insetRight?: number;
112
+ insetTop?: number;
109
113
  maxHeight?: DrawerDimension;
110
114
  maxWidth?: DrawerDimension;
111
115
  onOpen: () => void;
@@ -113,6 +117,6 @@ type DrawerEdgeSwipeProps = {
113
117
  translateOffset: SharedValue<number>;
114
118
  width?: DrawerDimension;
115
119
  };
116
- declare const DrawerEdgeSwipe: ({ edgeInset, enabled, height, maxHeight, maxWidth, onOpen, side, translateOffset, width }: DrawerEdgeSwipeProps) => react.JSX.Element;
120
+ declare const DrawerEdgeSwipe: ({ edgeInset, enabled, height, insetBottom, insetLeft, insetRight, insetTop, maxHeight, maxWidth, onOpen, side, translateOffset, width }: DrawerEdgeSwipeProps) => react.JSX.Element;
117
121
 
118
122
  export { type AutoPaperModule, type CreateDrawerOptions, type CreateDrawerResult, Drawer, type DrawerActions, type DrawerConfig, type DrawerDimension, DrawerEdgeSwipe, type DrawerEdgeSwipeProps, type DrawerInstanceProviderComponent, type DrawerInstanceProviderProps, type DrawerProps, DrawerProvider, type DrawerProviderProps, type DrawerSide, combineDrawerProviders, configureDrawer, createDrawer, getDrawerConfig };
package/dist/index.js CHANGED
@@ -137,7 +137,8 @@ var Drawer = ({ backdropOpacity = 0.45, blockingBackdrop = true, blur, children,
137
137
  const drawerStyle = (0, import_react_native_reanimated.useAnimatedStyle)(() => ({ transform: [vertical ? { translateY: translateOffset.value } : { translateX: translateOffset.value }] }));
138
138
  const backdropStyle = (0, import_react_native_reanimated.useAnimatedStyle)(() => ({ opacity: maxEffectiveSize > 0 ? (1 - Math.abs(translateOffset.value) / maxEffectiveSize) * backdropOpacity : 0 }));
139
139
  const animatedSizeStyle = (0, import_react_native_reanimated.useAnimatedStyle)(() => vertical ? { height: animatedSize.value } : { width: animatedSize.value });
140
- const backdropInteractionStyle = { zIndex, pointerEvents: open && blockingBackdrop ? "auto" : "none" };
140
+ const backdropInteractionStyle = { zIndex, pointerEvents: open && blockingBackdrop ? "box-none" : "none" };
141
+ const backdropTapAreaStyle = side === "left" ? { left: maxEffectiveSize } : side === "right" ? { right: maxEffectiveSize } : side === "top" ? { top: maxEffectiveSize } : { bottom: maxEffectiveSize };
141
142
  const positionStyle = side === "left" ? styles.anchorLeft : side === "right" ? styles.anchorRight : side === "top" ? styles.anchorTop : styles.anchorBottom;
142
143
  const sizeStyle = vertical ? { height: maxEffectiveSize } : { width: maxEffectiveSize };
143
144
  const handleLayout = (event) => {
@@ -212,13 +213,13 @@ var Drawer = ({ backdropOpacity = 0.45, blockingBackdrop = true, blur, children,
212
213
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
213
214
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native_reanimated.default.View, { style: [styles.backdropPosition, backdropInteractionStyle], children: [
214
215
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native_reanimated.default.View, { style: [styles.backdropTint, backdropStyle], pointerEvents: "none" }),
215
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native_gesture_handler.GestureDetector, { gesture: backdropTapGesture, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native_reanimated.default.View, { collapsable: false, style: import_react_native2.StyleSheet.absoluteFill }) })
216
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native_gesture_handler.GestureDetector, { gesture: backdropTapGesture, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native_reanimated.default.View, { collapsable: false, style: [import_react_native2.StyleSheet.absoluteFill, backdropTapAreaStyle] }) })
216
217
  ] }),
217
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native_reanimated.default.View, { style: drawerOuterStyle, children: [
218
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.View, { pointerEvents: "box-none", style: styles.panelClip, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native_reanimated.default.View, { style: drawerOuterStyle, children: [
218
219
  resolvedPanelShadow && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native_reanimated.default.View, { pointerEvents: "none", style: [import_react_native2.StyleSheet.absoluteFill, panelShadowStyle, panelShadowVisibilityStyle] }),
219
220
  contentSize ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.View, { style: contentClipStyle, children: fill }) : fill,
220
221
  dismissible && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native_gesture_handler.GestureDetector, { gesture: handleGesture, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native_reanimated.default.View, { style: [styles.handleStrip, handleStripSizeStyle, handleStripEdgeStyle, handleStripPaddingStyle, webCursorStyle2, handleVisibilityStyle, handleStripInteractionStyle], children: showHandle && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.View, { style: [styles.handlePill, handlePillStyle, { backgroundColor: colors.surface }] }) }) })
221
- ] })
222
+ ] }) })
222
223
  ] });
223
224
  };
224
225
  var styles = import_react_native2.StyleSheet.create({
@@ -270,6 +271,16 @@ var styles = import_react_native2.StyleSheet.create({
270
271
  alignItems: "center",
271
272
  justifyContent: "center",
272
273
  position: "absolute"
274
+ },
275
+ // See the comment above <View style={styles.panelClip}> in the render — the unconditional clip
276
+ // ancestor that keeps a translated-off-screen "closed" panel from inflating page scroll extent.
277
+ panelClip: {
278
+ bottom: 0,
279
+ left: 0,
280
+ overflow: "hidden",
281
+ position: "absolute",
282
+ right: 0,
283
+ top: 0
273
284
  }
274
285
  });
275
286
 
@@ -281,7 +292,7 @@ var import_jsx_runtime3 = require("react/jsx-runtime");
281
292
  var EDGE_WIDTH = 24;
282
293
  var SPRING2 = { damping: 45, overshootClamping: true, stiffness: 500, restDisplacementThreshold: 0.5, restSpeedThreshold: 10 };
283
294
  var VELOCITY_THRESHOLD2 = 500;
284
- var DrawerEdgeSwipe = ({ edgeInset = 0, enabled = true, height = 300, maxHeight, maxWidth, onOpen, side = "left", translateOffset, width = 300 }) => {
295
+ var DrawerEdgeSwipe = ({ edgeInset = 0, enabled = true, height = 300, insetBottom = 0, insetLeft = 0, insetRight = 0, insetTop = 0, maxHeight, maxWidth, onOpen, side = "left", translateOffset, width = 300 }) => {
285
296
  const vertical = isVerticalSide(side);
286
297
  const { closedOffset, effectiveSize, restOffset } = useDrawerSize(side, vertical ? height : width, vertical ? maxHeight : maxWidth, edgeInset);
287
298
  const openDirection = getOpenDirection(side);
@@ -304,7 +315,7 @@ var DrawerEdgeSwipe = ({ edgeInset = 0, enabled = true, height = 300, maxHeight,
304
315
  translateOffset.value = (0, import_react_native_reanimated2.withSpring)(closedOffset, SPRING2);
305
316
  }
306
317
  });
307
- const edgeStyle = vertical ? [styles2.edgeHorizontal, side === "top" ? styles2.top : styles2.bottom] : [styles2.edgeVertical, side === "left" ? styles2.left : styles2.right];
318
+ const edgeStyle = vertical ? [styles2.edgeHorizontal, side === "top" ? styles2.top : styles2.bottom, { left: insetLeft, right: insetRight }] : [styles2.edgeVertical, side === "left" ? styles2.left : styles2.right, { bottom: insetBottom, top: insetTop }];
308
319
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native_gesture_handler2.GestureDetector, { gesture, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native3.View, { style: [...edgeStyle, webCursorStyle, enabled ? styles2.interactive : styles2.nonInteractive] }) });
309
320
  };
310
321
  var webCursorStyle = { cursor: import_react_native3.Platform.OS === "web" ? "pointer" : void 0 };
package/dist/index.mjs CHANGED
@@ -95,7 +95,8 @@ var Drawer = ({ backdropOpacity = 0.45, blockingBackdrop = true, blur, children,
95
95
  const drawerStyle = useAnimatedStyle(() => ({ transform: [vertical ? { translateY: translateOffset.value } : { translateX: translateOffset.value }] }));
96
96
  const backdropStyle = useAnimatedStyle(() => ({ opacity: maxEffectiveSize > 0 ? (1 - Math.abs(translateOffset.value) / maxEffectiveSize) * backdropOpacity : 0 }));
97
97
  const animatedSizeStyle = useAnimatedStyle(() => vertical ? { height: animatedSize.value } : { width: animatedSize.value });
98
- const backdropInteractionStyle = { zIndex, pointerEvents: open && blockingBackdrop ? "auto" : "none" };
98
+ const backdropInteractionStyle = { zIndex, pointerEvents: open && blockingBackdrop ? "box-none" : "none" };
99
+ const backdropTapAreaStyle = side === "left" ? { left: maxEffectiveSize } : side === "right" ? { right: maxEffectiveSize } : side === "top" ? { top: maxEffectiveSize } : { bottom: maxEffectiveSize };
99
100
  const positionStyle = side === "left" ? styles.anchorLeft : side === "right" ? styles.anchorRight : side === "top" ? styles.anchorTop : styles.anchorBottom;
100
101
  const sizeStyle = vertical ? { height: maxEffectiveSize } : { width: maxEffectiveSize };
101
102
  const handleLayout = (event) => {
@@ -170,13 +171,13 @@ var Drawer = ({ backdropOpacity = 0.45, blockingBackdrop = true, blur, children,
170
171
  return /* @__PURE__ */ jsxs(Fragment2, { children: [
171
172
  /* @__PURE__ */ jsxs(Animated.View, { style: [styles.backdropPosition, backdropInteractionStyle], children: [
172
173
  /* @__PURE__ */ jsx2(Animated.View, { style: [styles.backdropTint, backdropStyle], pointerEvents: "none" }),
173
- /* @__PURE__ */ jsx2(GestureDetector, { gesture: backdropTapGesture, children: /* @__PURE__ */ jsx2(Animated.View, { collapsable: false, style: StyleSheet.absoluteFill }) })
174
+ /* @__PURE__ */ jsx2(GestureDetector, { gesture: backdropTapGesture, children: /* @__PURE__ */ jsx2(Animated.View, { collapsable: false, style: [StyleSheet.absoluteFill, backdropTapAreaStyle] }) })
174
175
  ] }),
175
- /* @__PURE__ */ jsxs(Animated.View, { style: drawerOuterStyle, children: [
176
+ /* @__PURE__ */ jsx2(View, { pointerEvents: "box-none", style: styles.panelClip, children: /* @__PURE__ */ jsxs(Animated.View, { style: drawerOuterStyle, children: [
176
177
  resolvedPanelShadow && /* @__PURE__ */ jsx2(Animated.View, { pointerEvents: "none", style: [StyleSheet.absoluteFill, panelShadowStyle, panelShadowVisibilityStyle] }),
177
178
  contentSize ? /* @__PURE__ */ jsx2(View, { style: contentClipStyle, children: fill }) : fill,
178
179
  dismissible && /* @__PURE__ */ jsx2(GestureDetector, { gesture: handleGesture, children: /* @__PURE__ */ jsx2(Animated.View, { style: [styles.handleStrip, handleStripSizeStyle, handleStripEdgeStyle, handleStripPaddingStyle, webCursorStyle2, handleVisibilityStyle, handleStripInteractionStyle], children: showHandle && /* @__PURE__ */ jsx2(View, { style: [styles.handlePill, handlePillStyle, { backgroundColor: colors.surface }] }) }) })
179
- ] })
180
+ ] }) })
180
181
  ] });
181
182
  };
182
183
  var styles = StyleSheet.create({
@@ -228,6 +229,16 @@ var styles = StyleSheet.create({
228
229
  alignItems: "center",
229
230
  justifyContent: "center",
230
231
  position: "absolute"
232
+ },
233
+ // See the comment above <View style={styles.panelClip}> in the render — the unconditional clip
234
+ // ancestor that keeps a translated-off-screen "closed" panel from inflating page scroll extent.
235
+ panelClip: {
236
+ bottom: 0,
237
+ left: 0,
238
+ overflow: "hidden",
239
+ position: "absolute",
240
+ right: 0,
241
+ top: 0
231
242
  }
232
243
  });
233
244
 
@@ -239,7 +250,7 @@ import { jsx as jsx3 } from "react/jsx-runtime";
239
250
  var EDGE_WIDTH = 24;
240
251
  var SPRING2 = { damping: 45, overshootClamping: true, stiffness: 500, restDisplacementThreshold: 0.5, restSpeedThreshold: 10 };
241
252
  var VELOCITY_THRESHOLD2 = 500;
242
- var DrawerEdgeSwipe = ({ edgeInset = 0, enabled = true, height = 300, maxHeight, maxWidth, onOpen, side = "left", translateOffset, width = 300 }) => {
253
+ var DrawerEdgeSwipe = ({ edgeInset = 0, enabled = true, height = 300, insetBottom = 0, insetLeft = 0, insetRight = 0, insetTop = 0, maxHeight, maxWidth, onOpen, side = "left", translateOffset, width = 300 }) => {
243
254
  const vertical = isVerticalSide(side);
244
255
  const { closedOffset, effectiveSize, restOffset } = useDrawerSize(side, vertical ? height : width, vertical ? maxHeight : maxWidth, edgeInset);
245
256
  const openDirection = getOpenDirection(side);
@@ -262,7 +273,7 @@ var DrawerEdgeSwipe = ({ edgeInset = 0, enabled = true, height = 300, maxHeight,
262
273
  translateOffset.value = withSpring2(closedOffset, SPRING2);
263
274
  }
264
275
  });
265
- const edgeStyle = vertical ? [styles2.edgeHorizontal, side === "top" ? styles2.top : styles2.bottom] : [styles2.edgeVertical, side === "left" ? styles2.left : styles2.right];
276
+ const edgeStyle = vertical ? [styles2.edgeHorizontal, side === "top" ? styles2.top : styles2.bottom, { left: insetLeft, right: insetRight }] : [styles2.edgeVertical, side === "left" ? styles2.left : styles2.right, { bottom: insetBottom, top: insetTop }];
266
277
  return /* @__PURE__ */ jsx3(GestureDetector2, { gesture, children: /* @__PURE__ */ jsx3(View2, { style: [...edgeStyle, webCursorStyle, enabled ? styles2.interactive : styles2.nonInteractive] }) });
267
278
  };
268
279
  var webCursorStyle = { cursor: Platform2.OS === "web" ? "pointer" : void 0 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rific/drawer",
3
- "version": "0.4.5",
3
+ "version": "0.5.1",
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",
@@ -62,9 +62,9 @@
62
62
  },
63
63
  "prettier": "@infinitetoken/eslint-config/prettier",
64
64
  "devDependencies": {
65
- "@infinitetoken/eslint-config": "^0.1.8",
66
- "@infinitetoken/jest-config": "^0.2.0",
67
- "@infinitetoken/tsconfig": "^0.3.0",
65
+ "@infinitetoken/eslint-config": "0.2.0",
66
+ "@infinitetoken/jest-config": "^0.3.0",
67
+ "@infinitetoken/tsconfig": "^0.4.1",
68
68
  "@rific/auto-paper": "^0.10.3",
69
69
  "@testing-library/dom": "^10.4.1",
70
70
  "@testing-library/react": "^16.3.2",
@@ -82,6 +82,7 @@
82
82
  "react-native-gesture-handler": "^2.20.0",
83
83
  "react-native-paper": "^5.12.0",
84
84
  "react-native-reanimated": "^4.5.1",
85
+ "react-native-safe-area-context": "^5.5.2",
85
86
  "react-native-worklets": "^0.10.3",
86
87
  "tsup": "^8.0.0",
87
88
  "typescript": "^6.0.3"
package/src/Drawer.tsx CHANGED
@@ -212,7 +212,27 @@ export const Drawer = ({ backdropOpacity = 0.45, blockingBackdrop = true, blur,
212
212
  // transparent, matching "closed," since a not-yet-sized panel isn't meaningfully open yet either.
213
213
  const backdropStyle = useAnimatedStyle(() => ({ opacity: maxEffectiveSize > 0 ? (1 - Math.abs(translateOffset.value) / maxEffectiveSize) * backdropOpacity : 0 }))
214
214
  const animatedSizeStyle = useAnimatedStyle(() => (vertical ? { height: animatedSize.value } : { width: animatedSize.value }))
215
- const backdropInteractionStyle: ViewStyle = { zIndex, pointerEvents: open && blockingBackdrop ? 'auto' : 'none' }
215
+ // 'box-none' (not 'auto'): this wrapper is just a positioning shell around the dimming tint and
216
+ // the actual tap-catching view below — on react-native-web, an ancestor's own explicit zIndex
217
+ // wins hit-testing over a plain-DOM-order sibling's z-index:auto descendants (panelClip, wrapping
218
+ // the panel, never sets its own zIndex — only ITS child does), so this wrapper being 'auto' made
219
+ // its own full-screen box outrank the panel for every click anywhere on screen, even where the
220
+ // panel visually covers it — a tap on real panel content (e.g. a settings toggle) would land on
221
+ // this inert wrapper instead and silently do nothing. 'box-none' keeps the wrapper itself out of
222
+ // hit-testing while still letting its own children (the tap-catcher below) receive touches within
223
+ // their own (now-shrunk, see backdropTapAreaStyle) bounds — exactly the "auto" behavior this was
224
+ // meant to have, minus the container falsely claiming space it doesn't actually own.
225
+ const backdropInteractionStyle: ViewStyle = { zIndex, pointerEvents: open && blockingBackdrop ? 'box-none' : 'none' }
226
+ // react-native-gesture-handler's web backend resolves a Gesture.Tap's hit region from this
227
+ // view's own measured bounds, not from real DOM occlusion/z-index the way native UIKit/Android
228
+ // hit-testing does — so on web, a tap landing anywhere on the (opaque, higher-zIndex) panel on
229
+ // top of this backdrop was still satisfying the backdrop's OWN Tap gesture underneath it,
230
+ // closing the drawer out from under a perfectly normal tap on its content (e.g. a toggle inside
231
+ // a settings panel). Native is unaffected (its real view hierarchy already occludes correctly),
232
+ // but shrinking this view's own bounds to exclude the panel's footprint is correct on every
233
+ // platform regardless — that region was always hidden behind the opaque panel anyway, so this
234
+ // changes nothing observable, it just stops the gesture from being reachable there at all.
235
+ const backdropTapAreaStyle: ViewStyle = side === 'left' ? { left: maxEffectiveSize } : side === 'right' ? { right: maxEffectiveSize } : side === 'top' ? { top: maxEffectiveSize } : { bottom: maxEffectiveSize }
216
236
 
217
237
  const positionStyle = side === 'left' ? styles.anchorLeft : side === 'right' ? styles.anchorRight : side === 'top' ? styles.anchorTop : styles.anchorBottom
218
238
  // maxEffectiveSize, not the raw height/width prop: the box must be big enough to show the panel
@@ -464,34 +484,58 @@ export const Drawer = ({ backdropOpacity = 0.45, blockingBackdrop = true, blur,
464
484
  {/* collapsable={false}: this view has no paint properties of its own (no background,
465
485
  no animated style), exactly the shape React Native's view-flattening optimizer removes
466
486
  from the native tree on native platforms — leaving the GestureDetector above with no real
467
- view left to attach its tap recognizer to, so it would silently never receive a touch. */}
468
- <Animated.View collapsable={false} style={StyleSheet.absoluteFill} />
487
+ view left to attach its tap recognizer to, so it would silently never receive a touch.
488
+ backdropTapAreaStyle shrinks this view's own bounds to exclude the panel's footprint —
489
+ see its own comment above for why that matters specifically on web. */}
490
+ <Animated.View collapsable={false} style={[StyleSheet.absoluteFill, backdropTapAreaStyle]} />
469
491
  </GestureDetector>
470
492
  </Animated.View>
471
- <Animated.View style={drawerOuterStyle}>
472
- {/* pointerEvents='none': purely decorative, drawn outside the panel's own box (a directional
473
- box-shadow never paints over the box's own content area), so it has no business
474
- intercepting anything even at full opacity. Absolutely filled to the panel's own current
475
- bounds, contentSize included, rather than a fixed size, so it tracks that animation too. */}
476
- {resolvedPanelShadow && <Animated.View pointerEvents='none' style={[StyleSheet.absoluteFill, panelShadowStyle, panelShadowVisibilityStyle]} />}
477
- {contentSize ? <View style={contentClipStyle}>{fill}</View> : fill}
478
- {dismissible && (
479
- <GestureDetector gesture={handleGesture}>
480
- {/* pointerEvents mirrors handleGesture's own .enabled(open) above, the same way the
481
- backdrop's tap-catcher mirrors backdropTapGesture's .enabled(open && blockingBackdrop)
482
- just above — handleVisibilityStyle's opacity already fades this strip out once the
483
- panel's closed, but opacity alone doesn't stop hit-testing on web/Android (unlike iOS,
484
- which excludes opacity-0 views from hit-testing regardless of pointerEvents — see the
485
- backdrop tint's own comment on that asymmetry). Left at 'auto' while closed, this
486
- 48px-wide strip sits at zIndex+2 flush against the screen edge closest to `side` —
487
- easy to land a consumer's own edge-anchored chrome (an app bar icon, say) in that same
488
- band — and swallows taps meant for whatever's underneath it despite being invisible
489
- AND, since the gesture itself is disabled here too, unable to do anything with them
490
- either. */}
491
- <Animated.View style={[styles.handleStrip, handleStripSizeStyle, handleStripEdgeStyle, handleStripPaddingStyle, webCursorStyle, handleVisibilityStyle, handleStripInteractionStyle]}>{showHandle && <View style={[styles.handlePill, handlePillStyle, { backgroundColor: colors.surface }]} />}</Animated.View>
492
- </GestureDetector>
493
- )}
494
- </Animated.View>
493
+ {/* panelClip is a NEW, unconditional clipping ancestor around the panel — NOT the same box as
494
+ drawerOuterStyle/styles.drawer, and deliberately not itself transformed. drawerOuterStyle
495
+ carries the open/closed translate (drawerStyle) and is anchored flush to its edge at its
496
+ FULL maxEffectiveSize (sizeStyle) — so a "closed" panel is never actually removed from the
497
+ tree, only slid to closedOffset, which for side='right'/'bottom' lands at a POSITIVE
498
+ coordinate just past the visible edge (see geometry.ts's getClosedOffset — left/top land at
499
+ NEGATIVE coordinates instead, which ordinary page scroll can't reach, which is why this only
500
+ ever showed up on right/bottom drawers). With nothing upstream constraining that positive
501
+ offset, react-native-web's host page treats the translated-but-still-full-size panel as real
502
+ document content sitting just outside the viewport, which grows the page's scrollable area —
503
+ scrolling into it reveals a fully rendered "closed" panel. Adding overflow:'hidden' directly
504
+ to styles.drawer itself is NOT the fix: that's the same box the transform moves, so its own
505
+ clip region would travel with it and cut off the handle strip below, which is deliberately
506
+ positioned outside drawerOuterStyle's bounds (see its own comment). panelClip instead fills
507
+ the drawer's whole mount area (never itself transformed) and clips ITS bounds, which stay
508
+ fixed regardless of where the translated panel inside it currently sits — so the handle strip
509
+ (well within panelClip's much larger box) is unaffected, while a closed panel translated past
510
+ panelClip's edge is clipped from paint and stops contributing to page scroll extent.
511
+ pointerEvents='box-none': this wrapper spans the full mount area purely to establish the clip
512
+ boundary — it must never itself catch a touch, only its real content underneath should. */}
513
+ <View pointerEvents='box-none' style={styles.panelClip}>
514
+ <Animated.View style={drawerOuterStyle}>
515
+ {/* pointerEvents='none': purely decorative, drawn outside the panel's own box (a directional
516
+ box-shadow never paints over the box's own content area), so it has no business
517
+ intercepting anything even at full opacity. Absolutely filled to the panel's own current
518
+ bounds, contentSize included, rather than a fixed size, so it tracks that animation too. */}
519
+ {resolvedPanelShadow && <Animated.View pointerEvents='none' style={[StyleSheet.absoluteFill, panelShadowStyle, panelShadowVisibilityStyle]} />}
520
+ {contentSize ? <View style={contentClipStyle}>{fill}</View> : fill}
521
+ {dismissible && (
522
+ <GestureDetector gesture={handleGesture}>
523
+ {/* pointerEvents mirrors handleGesture's own .enabled(open) above, the same way the
524
+ backdrop's tap-catcher mirrors backdropTapGesture's .enabled(open && blockingBackdrop)
525
+ just above — handleVisibilityStyle's opacity already fades this strip out once the
526
+ panel's closed, but opacity alone doesn't stop hit-testing on web/Android (unlike iOS,
527
+ which excludes opacity-0 views from hit-testing regardless of pointerEvents — see the
528
+ backdrop tint's own comment on that asymmetry). Left at 'auto' while closed, this
529
+ 48px-wide strip sits at zIndex+2 flush against the screen edge closest to `side` —
530
+ easy to land a consumer's own edge-anchored chrome (an app bar icon, say) in that same
531
+ band — and swallows taps meant for whatever's underneath it despite being invisible
532
+ AND, since the gesture itself is disabled here too, unable to do anything with them
533
+ either. */}
534
+ <Animated.View style={[styles.handleStrip, handleStripSizeStyle, handleStripEdgeStyle, handleStripPaddingStyle, webCursorStyle, handleVisibilityStyle, handleStripInteractionStyle]}>{showHandle && <View style={[styles.handlePill, handlePillStyle, { backgroundColor: colors.surface }]} />}</Animated.View>
535
+ </GestureDetector>
536
+ )}
537
+ </Animated.View>
538
+ </View>
495
539
  </>
496
540
  )
497
541
  }
@@ -545,5 +589,15 @@ const styles = StyleSheet.create({
545
589
  alignItems: 'center',
546
590
  justifyContent: 'center',
547
591
  position: 'absolute'
592
+ },
593
+ // See the comment above <View style={styles.panelClip}> in the render — the unconditional clip
594
+ // ancestor that keeps a translated-off-screen "closed" panel from inflating page scroll extent.
595
+ panelClip: {
596
+ bottom: 0,
597
+ left: 0,
598
+ overflow: 'hidden',
599
+ position: 'absolute',
600
+ right: 0,
601
+ top: 0
548
602
  }
549
603
  })
@@ -19,6 +19,15 @@ export type DrawerEdgeSwipeProps = {
19
19
  edgeInset?: number
20
20
  enabled?: boolean
21
21
  height?: DrawerDimension
22
+ // Shrink the strip's span along its long axis, to clear chrome (a header, a tab bar, ...) that
23
+ // would otherwise have its own touches stolen by this gesture — only the pair perpendicular to
24
+ // `side`'s own strip thickness applies: insetTop/insetBottom for a left/right drawer's vertical
25
+ // strip, insetLeft/insetRight for a top/bottom drawer's horizontal one. The other pair is
26
+ // ignored. All default to 0 (the strip's prior, full-length behavior).
27
+ insetBottom?: number
28
+ insetLeft?: number
29
+ insetRight?: number
30
+ insetTop?: number
22
31
  // Mirrors Drawer's own maxHeight: when set, an edge swipe still only opens to `height` (the rest
23
32
  // size), not all the way to this ceiling — matching Drawer's tap-to-open behavior, which also
24
33
  // lands at rest. Reaching past rest, up to maxHeight, is only ever done via Drawer's own handle.
@@ -31,7 +40,7 @@ export type DrawerEdgeSwipeProps = {
31
40
  width?: DrawerDimension
32
41
  }
33
42
 
34
- export const DrawerEdgeSwipe = ({ edgeInset = 0, enabled = true, height = 300, maxHeight, maxWidth, onOpen, side = 'left', translateOffset, width = 300 }: DrawerEdgeSwipeProps) => {
43
+ export const DrawerEdgeSwipe = ({ edgeInset = 0, enabled = true, height = 300, insetBottom = 0, insetLeft = 0, insetRight = 0, insetTop = 0, maxHeight, maxWidth, onOpen, side = 'left', translateOffset, width = 300 }: DrawerEdgeSwipeProps) => {
35
44
  const vertical = isVerticalSide(side)
36
45
  const { closedOffset, effectiveSize, restOffset } = useDrawerSize(side, vertical ? height : width, vertical ? maxHeight : maxWidth, edgeInset)
37
46
  const openDirection = getOpenDirection(side)
@@ -71,7 +80,7 @@ export const DrawerEdgeSwipe = ({ edgeInset = 0, enabled = true, height = 300, m
71
80
  }
72
81
  })
73
82
 
74
- const edgeStyle = vertical ? [styles.edgeHorizontal, side === 'top' ? styles.top : styles.bottom] : [styles.edgeVertical, side === 'left' ? styles.left : styles.right]
83
+ const edgeStyle = vertical ? [styles.edgeHorizontal, side === 'top' ? styles.top : styles.bottom, { left: insetLeft, right: insetRight }] : [styles.edgeVertical, side === 'left' ? styles.left : styles.right, { bottom: insetBottom, top: insetTop }]
75
84
 
76
85
  return (
77
86
  <GestureDetector gesture={gesture}>