react-native-draggable icon indicating copy to clipboard operation
react-native-draggable copied to clipboard

How to move the element to certain positions ?

Open bittu1028 opened this issue 4 years ago • 1 comments

 <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 ?

bittu1028 avatar Jun 16 '20 07:06 bittu1028

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.

MaiconGilton avatar Jul 01 '20 22:07 MaiconGilton