@rific/drawer 0.5.0 → 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/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
 
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rific/drawer",
3
- "version": "0.5.0",
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",
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
  })