, но вместо этого после добавления pagex и page к соответствующему и top - абсолютное представление.
Код: Выделить всё
import { Image } from "expo-image";
import React, { useRef } from "react";
import { Button, StyleSheet, Text, View } from "react-native";
import Animated, {
useAnimatedStyle,
useSharedValue,
} from "react-native-reanimated";
const AnimatedExpoImage = Animated.createAnimatedComponent(Image);
const Example = () => {
const imageViewRef = useRef(null);
const rootViewRef = useRef(null);
const position = useSharedValue({ x: 0, y: 0 });
const size = useSharedValue({ width: 0, height: 0 });
const activeImagePositionStyle = useAnimatedStyle(() => {
return {
top: position.value.y,
left: position.value.x,
};
});
const activeImageSizeStyle = useAnimatedStyle(() => {
return {
height: size.value.height,
width: size.value.width,
};
});
return (
Paul Jarvis
{
imageViewRef.current?.measure(
(x, y, width, height, pageX, pageY) => {
position.value = { x: pageX, y: pageY };
size.value = { width, height };
}
);
}}
/>
);
};
export default Example;
const styles = StyleSheet.create({
image: {
width: null,
height: null,
position: "absolute",
top: 0,
left: 0,
},
});
Подробнее здесь: https://stackoverflow.com/questions/797 ... act-native