react-native-draggable
react-native-draggable copied to clipboard
How to move the element to certain positions ?
<Draggable
x={x}
y={y}
disabled={orientation === 'LANDSCAPE'}
>
<VideoPlayer updateXY={this.updateXY} videoHeight={200}/>
</Draggable>
I have this element and when the fullscreen is done on android the landscape view start from position x so I need to reset both x and y to zero to make landscape mode working ?
I did this:
const [shouldRender, setshouldRender] = React.useState(true)
React.useEffect(() => {
setshouldRender(false)
setTimeout(() => setshouldRender(true), 5)
}, [x, y])
if (!shouldRender) return null
return (
<Draggable x={x} y={y}>
<View style={styles.container}>
...
</View>
</Draggable>
)
Basically you should rerender the component after you set new values for x and y.