Skip to content
This repository has been archived by the owner on Sep 28, 2021. It is now read-only.

When closed it is instant. Is there a way to fix this? #451

Open
GitPut opened this issue Feb 27, 2021 · 0 comments
Open

When closed it is instant. Is there a way to fix this? #451

GitPut opened this issue Feb 27, 2021 · 0 comments

Comments

@GitPut
Copy link

GitPut commented Feb 27, 2021

`// /* eslint-disable react-hooks/exhaustive-deps */
import React, {useRef, useState} from 'react';
import {
StyleSheet,
View,
Text,
Dimensions,
SafeAreaView,
Animated,
TouchableOpacity,
Modal,
} from 'react-native';
import ImageViewer from 'react-native-image-zoom-viewer';

const windowWidth = Dimensions.get('window').width;
const windowHeight = Dimensions.get('window').height;

export default function ImageView({inputImage, style}) {
const imageCenter = useRef(new Animated.ValueXY()).current;
const currentImageY = useRef(0);
const currentImageX = useRef(0);
const [on, setOn] = useState('none');
const [visible, setVisible] = useState(false);

const image = [
{
url: '',
props: {
// Or you can set source directory.
source: inputImage,
},
},
];

const toCenter = () => {
setVisible(true);
setOn('auto');
const posY = windowHeight / 2 - currentImageY.current - 100;
const posX = windowWidth / 2 - currentImageX.current - 100;
// Animated.timing(imageCenter, {
// toValue: {x: posX, y: posY},
// duration: 500,
// useNativeDriver: false,
// }).start();
};
const toOrigin = () => {
setOn('none');
// Animated.timing(imageCenter, {
// toValue: {x: 0, y: 0},
// duration: 500,
// useNativeDriver: false,
// }).start();
};

return (



<Animated.Image
source={inputImage}
//source={require('./compressed.jpg')}
style={[
{
borderRadius: 22,
height: 200,
width: 200,
},
style,
{
transform: [
{translateY: imageCenter.y},
{translateX: imageCenter.x},
],
},
]}
/>



<ImageViewer
enableSwipeDown={true}
onSwipeDown={() => {
setVisible(false);
toOrigin();
}}
imageUrls={image}
/>


);
}
`

When I open it the image it flashes and opens a bit slower which is good. But when I use the slide down to close it instantly closes and does not look good. So could someone please help me so I can make it close slower

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant