-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement missing measurements on android (#6413)
## Summary Implement measurement of relative coordinates on Android. ## Test plan I've added more logic to runtime tests to include parent component changes in calculations. <details><summary> Example code to log measurement </summary> ```tsx import React from 'react'; import { Button, StyleSheet, View } from 'react-native'; import type { MeasuredDimensions } from 'react-native-reanimated'; import Animated, { measure, runOnUI, useAnimatedRef, useSharedValue, } from 'react-native-reanimated'; const EXPECTED_MEASUREMENT = { height: 100, pageX: 302, width: 80, x: 120, y: 150, }; export default function App() { const animatedRef = useAnimatedRef<Animated.View>(); const measurement = useSharedValue<MeasuredDimensions | null>(null); const handlePress = () => { runOnUI(() => { 'worklet'; measurement.value = measure(animatedRef); console.log(measurement.value); })(); }; return ( <View style={styles.container}> <View style={styles.bigBox}> <Animated.View ref={animatedRef} style={styles.box} /> </View> <Button onPress={handlePress} title="Click me" /> </View> ); } const styles = StyleSheet.create({ container: { flex: 1, }, bigBox: { position: 'absolute', top: 0, left: EXPECTED_MEASUREMENT.pageX - EXPECTED_MEASUREMENT.x, height: 300, width: 300, borderColor: '#b58df1', borderWidth: 2, }, box: { top: EXPECTED_MEASUREMENT.y, left: EXPECTED_MEASUREMENT.x, height: EXPECTED_MEASUREMENT.height, width: EXPECTED_MEASUREMENT.width, backgroundColor: '#b58df1', }, }); ``` </summary>
- Loading branch information
Showing
3 changed files
with
138 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters