I’m working with the react-native-draggable component.
return (
<View >
<Draggable x={75} y={100} renderSize={56} renderColor='black' renderText='A' isCircle shouldReverse onShortPressRelease={()=>alert('touched!!')}/>
<Draggable x={200} y={300} renderColor='red' renderText='B'/>
<Draggable/>
<Draggable x={50} y={50}>
<YourComponent/>
</Draggable>
</View>
);
By setting the shouldReverse prop to true, the draggable item smoothly returns to its original position.
However, I can’t seem to dynamically update the “original position” of the draggable item by updating the position.x and position.y values, as in the following code:
<View style={styles.answerContainer}>
{answerParts.map((item, index) => (
<Draggable
key={item.index}
x={item.position.x}
y={item.position.y}
disabled={item.placed}
shouldReverse={!item.placed}
onDragRelease={(event) => onReleaseItem(item, event)}
>
<View style={styles.draggableItem}>
<Text style={styles.draggableText}>{item.text}</Text>
</View>
</Draggable>
))}
</View>
Any thoughts on how I can properly change the original location of a draggable React Native component?
Thanks!
Anson