react-native-reanimated
Version:
More powerful alternative to Animated library for React Native.
29 lines (26 loc) • 876 B
JavaScript
import { measure } from './NativeMethods';
/**
* Given an absolute position and a component ref, returns the relative
* position in the component's local coordinate space.
*/
export function getRelativeCoords(parentAnimatedRef, absoluteX, absoluteY) {
'worklet';
const parentCoords = measure(parentAnimatedRef);
if (parentCoords === null) {
return null;
}
return {
x: absoluteX - parentCoords.x,
y: absoluteY - parentCoords.y
};
}
export function isSharedValue(value) {
'worklet';
return (value === null || value === void 0 ? void 0 : value._isReanimatedSharedValue) === true;
}
// This is Jest implementation of `requestAnimationFrame` that is required
// by React Native for test purposes.
export function mockedRequestAnimationFrame(callback) {
return setTimeout(() => callback(performance.now()), 0);
}
//# sourceMappingURL=utils.js.map