@@ -17,6 +17,11 @@ import Animated, {
17
17
useSharedValue ,
18
18
} from "react-native-reanimated" ;
19
19
20
+ const multiply = ( ...matrices : Matrix4 [ ] ) => {
21
+ "worklet" ;
22
+ return matrices . reduce ( ( acc , matrix ) => multiply4 ( acc , matrix ) , Matrix4 ( ) ) ;
23
+ } ;
24
+
20
25
interface GestureHandlerProps {
21
26
matrix : SharedValue < Matrix4 > ;
22
27
dimensions : SkRect ;
@@ -60,7 +65,12 @@ export const GestureHandler = ({
60
65
} ) ;
61
66
62
67
const style = useAnimatedStyle ( ( ) => {
63
- const m4 = convertToColumnMajor ( matrix . value ) ;
68
+ const m = multiply (
69
+ translate ( - width / 2 , - height / 2 ) ,
70
+ matrix . value ,
71
+ translate ( width / 2 , height / 2 )
72
+ ) ;
73
+ const m4 = convertToColumnMajor ( m ) ;
64
74
return {
65
75
position : "absolute" ,
66
76
left : x ,
@@ -69,16 +79,12 @@ export const GestureHandler = ({
69
79
height,
70
80
backgroundColor : debug ? "rgba(100, 200, 300, 0.4)" : "transparent" ,
71
81
transform : [
72
- { translateX : - width / 2 } ,
73
- { translateY : - height / 2 } ,
74
82
{
75
83
matrix :
76
84
Platform . OS === "web"
77
85
? convertToAffineMatrix ( m4 )
78
86
: ( m4 as unknown as number [ ] ) ,
79
87
} ,
80
- { translateX : width / 2 } ,
81
- { translateY : height / 2 } ,
82
88
] ,
83
89
} ;
84
90
} ) ;
0 commit comments