about summary refs log tree commit diff
path: root/src/lib/custom-animations/PressableScale.tsx
diff options
context:
space:
mode:
authordan <dan.abramov@gmail.com>2024-11-17 15:06:28 +0000
committerGitHub <noreply@github.com>2024-11-17 15:06:28 +0000
commit474c4eff29b6a2454a20febf78a1edd5cf58663a (patch)
tree43a189a8101cf3f5265d967ad46182cf8cbde9a0 /src/lib/custom-animations/PressableScale.tsx
parentd575a2fdaaa4d9c93d6b739dfe3377cdd5985dc1 (diff)
downloadvoidsky-474c4eff29b6a2454a20febf78a1edd5cf58663a.tar.zst
Use compiler-safe Reanimated get/set APIs (#6391)
* Convert lightbox to get/set

* Work around software-mansion/react-native-reanimated#6613

* Use get/set in more places

* Port MainScrollProvider to get/set

* Port more to get/set

* Port composer to get/set

* Remove unnecessary thread hops in composer

* Port more things to get/set

* Convert more to get/set, remove redundant runOnJS

* Convert remaining cases to get/set
Diffstat (limited to 'src/lib/custom-animations/PressableScale.tsx')
-rw-r--r--src/lib/custom-animations/PressableScale.tsx13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/lib/custom-animations/PressableScale.tsx b/src/lib/custom-animations/PressableScale.tsx
index 4737b9ea3..1e776546d 100644
--- a/src/lib/custom-animations/PressableScale.tsx
+++ b/src/lib/custom-animations/PressableScale.tsx
@@ -2,7 +2,6 @@ import React from 'react'
 import {Pressable, PressableProps, StyleProp, ViewStyle} from 'react-native'
 import Animated, {
   cancelAnimation,
-  runOnJS,
   useAnimatedStyle,
   useReducedMotion,
   useSharedValue,
@@ -32,27 +31,25 @@ export function PressableScale({
   const scale = useSharedValue(1)
 
   const animatedStyle = useAnimatedStyle(() => ({
-    transform: [{scale: scale.value}],
+    transform: [{scale: scale.get()}],
   }))
 
   return (
     <AnimatedPressable
       accessibilityRole="button"
       onPressIn={e => {
-        'worklet'
         if (onPressIn) {
-          runOnJS(onPressIn)(e)
+          onPressIn(e)
         }
         cancelAnimation(scale)
-        scale.value = withTiming(targetScale, {duration: 100})
+        scale.set(() => withTiming(targetScale, {duration: 100}))
       }}
       onPressOut={e => {
-        'worklet'
         if (onPressOut) {
-          runOnJS(onPressOut)(e)
+          onPressOut(e)
         }
         cancelAnimation(scale)
-        scale.value = withTiming(1, {duration: 100})
+        scale.set(() => withTiming(1, {duration: 100}))
       }}
       style={[!reducedMotion && animatedStyle, style]}
       {...rest}>