Skip to content

Commit d8fb917

Browse files
feat: update Pressable configuration to include baseScale and adjust scale interpolation
1 parent a2e4c86 commit d8fb917

2 files changed

Lines changed: 52 additions & 3 deletions

File tree

src/pressables/custom/scale.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const PressableScale = createAnimatedPressable((progress, { config }) =>
66
return {
77
transform: [
88
{
9-
scale: interpolate(progress, [0, 1], [config.maxScale, config.minScale]),
9+
scale: interpolate(progress, [0, 1], [config.baseScale, config.minScale]),
1010
},
1111
],
1212
};

src/provider/constants.ts

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,55 @@
11
import { Easing } from 'react-native-reanimated';
22

3+
/**
4+
* Configuration values for pressable visual feedback
5+
*/
36
export type PressableConfig = {
7+
/**
8+
* Target opacity when the pressable is in active/pressed state.
9+
*
10+
* Used by PressableOpacity to interpolate from 1 (idle) to this value (pressed).
11+
*
12+
* @default 0.5
13+
* @example
14+
* // More transparent when pressed
15+
* config={{ activeOpacity: 0.3 }}
16+
*
17+
* // Less transparent when pressed
18+
* config={{ activeOpacity: 0.7 }}
19+
*/
420
activeOpacity: number;
21+
22+
/**
23+
* Target scale when the pressable is in active/pressed state.
24+
*
25+
* Used by PressableScale to interpolate from baseScale (idle) to this value (pressed).
26+
* Values less than baseScale create a "shrink" effect.
27+
*
28+
* @default 0.96
29+
* @example
30+
* // More pronounced shrink effect
31+
* config={{ minScale: 0.9 }}
32+
*
33+
* // Subtle shrink effect
34+
* config={{ minScale: 0.98 }}
35+
*/
536
minScale: number;
6-
maxScale: number;
37+
38+
/**
39+
* Base scale when the pressable is in idle/unpressed state.
40+
*
41+
* Used by PressableScale as the starting scale value.
42+
* Typically set to 1, but can be adjusted for special effects.
43+
*
44+
* @default 1
45+
* @example
46+
* // Normal size when idle
47+
* config={{ baseScale: 1 }}
48+
*
49+
* // Slightly enlarged when idle (grows when pressed if minScale > 1)
50+
* config={{ baseScale: 1.05, minScale: 1.1 }}
51+
*/
52+
baseScale: number;
753
};
854

955
export const DefaultAnimationConfigs = {
@@ -15,8 +61,11 @@ export const DefaultAnimationConfigs = {
1561
},
1662
} as const;
1763

64+
/**
65+
* Default configuration values for pressable visual feedback
66+
*/
1867
export const DefaultPressableConfig: PressableConfig = {
1968
activeOpacity: 0.5,
2069
minScale: 0.96,
21-
maxScale: 1,
70+
baseScale: 1,
2271
} as const;

0 commit comments

Comments
 (0)