Commit 3e21b6c
authored
## Description
This PR adds `animationSpeed` to `ReanimatedDrawerLayout`.
I was conflicted between adding `animationSpeed: number`,
`animationOptions: DrawerMovementOption`, and `animationConfig:
Record<string, unknown>`.
- `animationConfig` is the most flexible one, but
`ReanimatedDrawerLayout` already opinionates animation configuration,
and doesn't allow for any configuration beyond `DrawerMovementOption`
- `DrawerMovementOption` is already in place, but we don't need
`initialVelocity` value for the default animation.
- since we only need animation speed, I think `animationSpeed: number`
makes the most sense
Suggested by #3392
Closes #3392
## Test plan
- see how both opening and dismissal animations are modified:
<details>
<summary>
Collapsed repro
</summary>
```tsx
import React, { useRef } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import {
Gesture,
GestureDetector,
GestureHandlerRootView,
} from 'react-native-gesture-handler';
import ReanimatedDrawerLayout, {
DrawerType,
DrawerPosition,
DrawerLayoutMethods,
DrawerLockMode,
} from 'react-native-gesture-handler/ReanimatedDrawerLayout';
const DrawerPage = () => {
return (
<View style={styles.drawerContainer}>
<Text>Lorem ipsum</Text>
</View>
);
};
export default function ReanimatedDrawerExample() {
const drawerRef = useRef<DrawerLayoutMethods>(null);
const tapGesture = Gesture.Tap()
.runOnJS(true)
.onStart(() => drawerRef.current?.openDrawer({ animationSpeed: 5000 }));
return (
<GestureHandlerRootView>
<ReanimatedDrawerLayout
ref={drawerRef}
animationSpeed={5000}
renderNavigationView={() => <DrawerPage />}
drawerLockMode={DrawerLockMode.UNLOCKED}
drawerPosition={DrawerPosition.LEFT}
drawerType={DrawerType.FRONT}>
<View style={styles.innerContainer}>
<GestureDetector gesture={tapGesture}>
<View style={styles.box}>
<Text>Open drawer</Text>
</View>
</GestureDetector>
</View>
</ReanimatedDrawerLayout>
</GestureHandlerRootView>
);
}
const styles = StyleSheet.create({
drawerContainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'pink',
},
innerContainer: {
flex: 1,
backgroundColor: 'white',
alignItems: 'center',
justifyContent: 'center',
gap: 20,
},
box: {
padding: 20,
backgroundColor: 'pink',
},
});
```
</details>
1 parent bb248de commit 3e21b6c
1 file changed
+10
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
146 | 152 | | |
147 | 153 | | |
148 | 154 | | |
| |||
292 | 298 | | |
293 | 299 | | |
294 | 300 | | |
| 301 | + | |
295 | 302 | | |
296 | 303 | | |
297 | 304 | | |
| |||
392 | 399 | | |
393 | 400 | | |
394 | 401 | | |
395 | | - | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
396 | 405 | | |
397 | 406 | | |
398 | 407 | | |
| |||
0 commit comments