react-native-images-preview
Version:
A React Native animated custom images preview component.
40 lines • 1.07 kB
JavaScript
import { useRef, useState } from 'react';
const useImagePreview = () => {
const [modalConfig, setModalConfig] = useState({
x: 0,
y: 0,
height: 0,
width: 0,
visible: false,
});
const imageRef = useRef(null);
const [loading, setLoading] = useState(false);
const [error, setError] = useState(false);
/**
* Use to get the position and size of image and set to modalConfig
*/
const onPressImage = () => {
var _a;
(_a = imageRef.current) === null || _a === void 0 ? void 0 : _a.measure((_ox, _oy, width, height, px, py) => {
setModalConfig({
x: px,
y: py,
width: width,
height: height,
visible: true,
});
});
};
return {
modalConfig,
setModalConfig,
onPressImage,
imageRef,
loading,
setLoading,
error,
setError,
};
};
export default useImagePreview;
//# sourceMappingURL=useImagePreview.js.map