Skip to content

Commit 1e01ea1

Browse files
refactor: update PressablesConfig animation settings and improve animated style dependencies
1 parent 3d612fa commit 1e01ea1

4 files changed

Lines changed: 5 additions & 9 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ function App() {
9797
export default () => (
9898
<PressablesConfig
9999
animationType="spring"
100-
config={{ mass: 2 }}
100+
config={{ mass: 1, damping: 30, stiffness: 200 }}
101101
globalHandlers={{
102102
onPress: () => {
103103
console.log('you can call haptics here');

example/app/_layout.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,7 @@ import { GestureHandlerRootView } from 'react-native-gesture-handler';
66
export default function RootLayout() {
77
return (
88
<PressablesConfig
9-
animationType="spring"
10-
config={{
11-
mass: 1,
12-
damping: 15,
13-
stiffness: 120,
14-
overshootClamping: false,
15-
}}
9+
animationType="timing"
1610
globalHandlers={{
1711
onPress: () => {
1812
console.log('use haptics!');

src/pressables/base.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ const BasePressable: React.FC<BasePressableProps> = React.memo(
117117

118118
const rAnimatedStyle = useAnimatedStyle(() => {
119119
return animatedStyle ? animatedStyle(progress) : {};
120-
}, []);
120+
}, [animatedStyle, progress]);
121121

122122
return (
123123
<AnimatedBaseButton

src/provider/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ export const DefaultConfigs = {
44
timing: { duration: 250, easing: Easing.bezier(0.25, 0.1, 0.25, 1) },
55
spring: {
66
mass: 1,
7+
damping: 30,
8+
stiffness: 200,
79
},
810
} as const;

0 commit comments

Comments
 (0)