feat: fixes and formatter
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import React, { useCallback, useEffect } from "react";
|
||||
import { Pressable } from "react-native";
|
||||
import React, { useCallback, useEffect } from 'react'
|
||||
import { Pressable } from 'react-native'
|
||||
import Animated, {
|
||||
cancelAnimation,
|
||||
useAnimatedStyle,
|
||||
useSharedValue,
|
||||
withSpring,
|
||||
} from "react-native-reanimated";
|
||||
} from 'react-native-reanimated'
|
||||
|
||||
export default function PressableScale({
|
||||
children,
|
||||
@@ -18,31 +18,31 @@ export default function PressableScale({
|
||||
spring = { damping: 18, stiffness: 220, mass: 0.8 },
|
||||
...rest
|
||||
}) {
|
||||
const sv = useSharedValue(1);
|
||||
const sv = useSharedValue(1)
|
||||
|
||||
const rStyle = useAnimatedStyle(() => ({
|
||||
transform: [{ scale: sv.value }],
|
||||
}));
|
||||
}))
|
||||
|
||||
const pressIn = useCallback(() => {
|
||||
if (disabled) return;
|
||||
cancelAnimation(sv);
|
||||
sv.value = 1;
|
||||
sv.value = withSpring(scaleTo, spring);
|
||||
}, [disabled, scaleTo, spring, sv]);
|
||||
if (disabled) return
|
||||
cancelAnimation(sv)
|
||||
sv.value = 1
|
||||
sv.value = withSpring(scaleTo, spring)
|
||||
}, [disabled, scaleTo, spring, sv])
|
||||
|
||||
const reset = useCallback(() => {
|
||||
cancelAnimation(sv);
|
||||
sv.value = withSpring(1, spring);
|
||||
}, [spring, sv]);
|
||||
cancelAnimation(sv)
|
||||
sv.value = withSpring(1, spring)
|
||||
}, [spring, sv])
|
||||
|
||||
useEffect(
|
||||
() => () => {
|
||||
cancelAnimation(sv);
|
||||
sv.value = 1;
|
||||
cancelAnimation(sv)
|
||||
sv.value = 1
|
||||
},
|
||||
[sv]
|
||||
);
|
||||
)
|
||||
|
||||
return (
|
||||
<Pressable
|
||||
@@ -54,8 +54,8 @@ export default function PressableScale({
|
||||
onMouseLeave={reset} // web
|
||||
onBlur={reset}
|
||||
onPress={(e) => {
|
||||
onPress?.(e);
|
||||
reset();
|
||||
onPress?.(e)
|
||||
reset()
|
||||
}}
|
||||
hitSlop={hitSlop}
|
||||
disabled={disabled}
|
||||
@@ -64,5 +64,5 @@ export default function PressableScale({
|
||||
>
|
||||
<Animated.View style={[contentStyle, rStyle]}>{children}</Animated.View>
|
||||
</Pressable>
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user