@rific/drawer 0.8.1 → 0.8.3

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.
Files changed (2) hide show
  1. package/README.md +7 -3
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -13,9 +13,11 @@ npm install @rific/drawer
13
13
  **Peer dependencies:**
14
14
 
15
15
  ```sh
16
- npm install react-native-gesture-handler react-native-reanimated react-native-paper
16
+ npm install @rific/core react-native-gesture-handler react-native-reanimated react-native-worklets react-native-paper
17
17
  ```
18
18
 
19
+ `@rific/core` (0.5.0+) lets the drawer's gestures call back into it without pinning it in memory, and `react-native-worklets` (0.5.0+, which Reanimated 4 already needs) carries those calls. React Native 0.83+, Reanimated 4+ and gesture-handler 2.20+ (2 or 3).
20
+
19
21
  Your app's root must already be wrapped in `GestureHandlerRootView` (from `react-native-gesture-handler`). This package doesn't add its own, since only one should ever wrap the whole app.
20
22
 
21
23
  Optionally install `@rific/auto-paper` as well and configure it via `DrawerProvider` to opt into blurred panels; see [Blur](#blur) below.
@@ -168,7 +170,7 @@ import * as AutoPaper from '@rific/auto-paper'
168
170
  configureDrawer({ autoPaper: AutoPaper })
169
171
  ```
170
172
 
171
- Either way this is one-time setup, not reactive state: call it once, before anything renders. Every `Drawer`, from any `createDrawer()` instance, picks it up automatically; there's nothing to pass per-drawer.
173
+ Either way this is one-time setup, not reactive state: call it once, before anything renders. Every `Drawer`, from any `createDrawer()` instance, picks it up automatically; there's nothing to pass per-drawer. `getDrawerConfig()` returns what was configured (a `DrawerConfig`, `{ autoPaper? }`).
172
174
 
173
175
  Pass `blur` wherever suits your app: to `createDrawer()` (a fixed default for that drawer), to `DrawerInstanceProvider` (overriding the `createDrawer()` default for that mount), or directly to `Drawer` if you're using it standalone. If you don't pass `blur` at all, the panel falls back to `@rific/auto-paper`'s own global `settings.blur` user preference via `useBlur()`.
174
176
 
@@ -182,7 +184,7 @@ Only the panel surface blurs; the backdrop behind it stays solid, same as today.
182
184
 
183
185
  `Drawer` (the sliding panel and backdrop) and `DrawerEdgeSwipe` (the edge gesture zone) are also exported directly, for apps that want to manage the open/closed state and shared value themselves instead of using `createDrawer()`. Both take a `translateOffset` prop, a `SharedValue<number>` holding the panel's offset along its axis (`translateX` for `left`/`right`, `translateY` for `top`/`bottom`), so `DrawerEdgeSwipe`'s gesture and `Drawer`'s spring animation can share the same value.
184
186
 
185
- Seed that shared value at the drawer's closed offset with `useDrawerSize`, the same hook `Drawer`, `DrawerEdgeSwipe` and `createDrawer()` resolve their own geometry with, rather than negating the size by hand: a hand-negated `-380` disagrees with a panel that's been capped to a narrower window (see [Usage](#usage)). Pass it the same `side`, size, max size and `edgeInset` the `Drawer` gets. Its `effectiveSize` is also the panel's actual rest size in px, for laying out anything sized to the panel itself (a full-width carousel page, say):
187
+ Seed that shared value at the drawer's closed offset with `useDrawerSize`, the same hook `Drawer`, `DrawerEdgeSwipe` and `createDrawer()` resolve their own geometry with, rather than negating the size by hand: a hand-negated `-380` disagrees with a panel that's been capped to a narrower window (see [Usage](#usage)). Pass it the same `side`, size, max size and `edgeInset` the `Drawer` gets. Its `effectiveSize` is also the panel's actual rest size in px, for laying out anything sized to the panel itself (a full-width carousel page, say). It also returns `maxEffectiveSize`, the panel's full size once a max size is resolved (the same as `effectiveSize` without one; see [Expandable sheets](#expandable-sheets)), and `restOffset`, where an open panel rests along its axis: `0` when it opens all the way, otherwise the offset that leaves `effectiveSize` on screen and the rest off it until dragged further:
186
188
 
187
189
  ```tsx
188
190
  import { Drawer, DrawerEdgeSwipe, useDrawerSize } from '@rific/drawer'
@@ -215,4 +217,6 @@ Both also take `maxHeight`/`maxWidth` (see [Expandable sheets](#expandable-sheet
215
217
 
216
218
  `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.
217
219
 
220
+ `Drawer` alone also takes `panelShadow` (default off), a shadow cast by the panel onto what's behind it: `true` for the defaults (2px distance, 8px blur, 30% black), or `{ distance?, blurRadius?, color?, elevation? }` to change any of them. `distance` is a magnitude: the shadow always falls away from the panel's own edge, whichever `side` it's on. `elevation` is Android's native shadow, drawn alongside and defaulting to `blurRadius`. It fades in and out with the panel, so a closed panel sitting flush against the screen edge leaves no line along it. `createDrawer()` doesn't pass it through.
221
+
218
222
  `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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rific/drawer",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
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,8 +62,8 @@
62
62
  },
63
63
  "prettier": "@infinitetoken/eslint-config/prettier",
64
64
  "devDependencies": {
65
- "@infinitetoken/eslint-config": "0.2.0",
66
- "@infinitetoken/jest-config": "^0.5.1",
65
+ "@infinitetoken/eslint-config": "0.2.1",
66
+ "@infinitetoken/jest-config": "^0.5.2",
67
67
  "@infinitetoken/tsconfig": "^0.6.0",
68
68
  "@rific/auto-paper": "^0.13.3",
69
69
  "@rific/core": "^0.5.0",