Skip to content

Commit 6700c8d

Browse files
committed
fix: multiple typos and unclear sentences fixed in the readme
1 parent 30c7114 commit 6700c8d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ The example app is running from [`./example/App.tsx`](./example/App.tsx)
109109
| `sensitivity` | `number` | `10` | The amount of pixels a drawer needs to slide to trigger state change (peek to open or open to peek). The smaller the value, the more sensitive the state change. Default to 10. |
110110
| `expandable` | `boolean` | `true` | A flag indicating whether a drawer is static (non-expandable) or dynamic (expandable). Default to true, i.e. the drawer is dynamic. |
111111
| `isInitialPeek` | `boolean` | `true` | A flag indicating whether the initial state of the drawer is peek or open. Default to true, i.e. the initial state is peek. |
112-
| `enableSlideOpen` | `boolean` | `true` | A flag indicating whether a drawer can be opened with sliding (e.g. open upon a button press). Default to true. |
112+
| `enableSlideOpen` | `boolean` | `true` | A flag indicating whether a drawer can be opened with sliding. Default to true. |
113113
| `enableNonSlideOpen` | `boolean` | `false` | A flag indicating whether a drawer can be opened without sliding (e.g. open upon a button press). Default to false. |
114114
| `nonSlideOpen` | `boolean` | `false` | A flag indicating whether to open or close a drawer. Applicable only when `enableNonSlideOpen` is set to true. Default to false, i.e. to close the drawer. |
115115
| `onDrawerOpen` | `() => void` | `() => {}` | A callback function when the drawer reaches the open state. See the caveat section for the particularity of its usage. Default to a no-operation function. |
@@ -128,7 +128,7 @@ Some caveats and gotchas while using `react-native-sliding-drawer`
128128

129129
`<SlidingDrawer></SlidingDrawer>` is sensitive to position. Its own position prop is set to "absolute", but if some of its parent components have restricting positioning or sizing, the rendered sliding drawer might have unexpected height, width, peek size, etc. It is thus highly recommended that `<SlidingDrawer></SlidingDrawer>` has as few parents as possible (i.e. it is coded as close to top level component as possible). This way, there is less risk of the sliding drawer being constraint by some other components. If, however, the sliding drawer must be deeply nested, make sure that each of its parent has loose positioning or sizing.
130130

131-
For instance, the minimal workable example is a valid way use `<SlidingDrawer></SlidingDrawer>`, because its parent spreads the entire screen. However, if we put a restricting style on the parent such as the one shown below
131+
For instance, the minimal workable example is a valid way to use `<SlidingDrawer></SlidingDrawer>`, because its parent spreads the entire screen. However, if we put a restricting style on the parent such as the one shown below
132132

133133
```js
134134
import * as React from 'react';
@@ -145,7 +145,7 @@ const App = () => {
145145
justifyContent: 'center',
146146
alignItems: 'center',
147147
backgroundColor: 'yellow',
148-
width: 100,
148+
width: 100, // restricting style
149149
}}>
150150
<Text>Minimal Example</Text>
151151
<SlidingDrawer peekSize={peekSize} openSize={openSize} fixedLoc="bottom">
@@ -165,7 +165,7 @@ const App = () => {
165165
export default App;
166166
```
167167

168-
The sliding drawer no longer behaves as expected
168+
The sliding drawer no longer behaves as expected (it doesn't cover the entire width of the screen)
169169

170170
![Sliding drawer under a restricting parent](./docs/images/caveats/restrictingParent/problem.gif)
171171

@@ -185,7 +185,7 @@ const App = () => {
185185
justifyContent: 'center',
186186
alignItems: 'center',
187187
backgroundColor: 'yellow',
188-
width: 100,
188+
width: 100, // restricting style
189189
}}>
190190
<Text>Minimal Example</Text>
191191
</View>
@@ -204,7 +204,7 @@ const App = () => {
204204
};
205205
```
206206

207-
Now the sliding drawer behavior is normal
207+
Now the sliding drawer behavior is normal (drawer covers the entire width of the screen)
208208

209209
![Sliding drawer taken out of a restricting parent](./docs/images/caveats/restrictingParent/solution.gif)
210210

@@ -284,12 +284,12 @@ export default App;
284284

285285
![Sliding does not work with dynamic variable](./docs/images/caveats/dynamicCallbackInSliding/problem.gif)
286286

287-
The desired behavior is that each time the drawer opens or closes, the counter counts up. We can see that the desired behavior is achieved using the non-slide open feature. However, when the drawer slides open or close, the counter gets stuck at 1. This is `onDrawerOpen` and `onDrawerPeek` are cached in a ref (hence, the value in `count` is forever the initialized value, which is 0) when the drawer is opened or closed via sliding. Any further change to `count` does not alter its cached value inside the ref. On the other hand, the two callbacks are NOT cached when the drawer is opened or closed via the non-slide open feature. Hence, the value in `count` does change.
287+
The desired behavior is that each time the drawer opens or closes, the counter counts up. We can see that the desired behavior is achieved using the non-slide open feature. However, when the drawer slides open or close, the counter gets stuck at 1. This is because `onDrawerOpen` and `onDrawerPeek` are cached in a ref when the drawer is opened or closed via sliding. Hence, the value in `count` is forever the initialized value, which is 0. Any further change to `count` does not alter its cached value inside the ref. On the other hand, if the drawer is opened or closed via the non-slide open feature, the callbacks are NOT cached; thus, their value in `count` does change.
288288

289289
There are two ways to work around this limtation.
290290

291291
1. If the values in the callback can be hard coded, do it! For instance, instead of using `setIsInitialPeek(!isInitialPeek)` for both `onDrawerOpen` and `onDrawerPeek`, hard code the true and false value.
292-
2. If including dynamic variables is inevitable for the two callbacks, consider disabling the slide open feature. This can be achieved by setting the prop `enableSlideOpen` to false.
292+
2. If including dynamic variables is inevitable for the two callbacks, consider disabling the slide open feature. In other words, force the user to open the drawer via the non-slide open feature, such that the callback is always executed as desired. This can be achieved by setting the prop `enableSlideOpen` to false.
293293

294294
Of course, if anyone has a solution to directly resolve this issue, please share your thoughts and open a pull request.
295295

0 commit comments

Comments
 (0)