Open
Description
Hello, firstly thanks for this beautiful library
I couldnt figure out how to get new positions of draggable after drag or while dragging to save state. I use latest version.
state={
elements: [
{
id:'somenode1',
type:'node',
position_x: 190,
position_y: 150,
node_width: 160,
node_height: 60,
data: {
title:'CHILD1'
}
},
...
<>
<View style={{backgroundColor:'#bbe1fa', borderTopColor:'#b8b5ff', height:SCREEN_HEIGHT, width:SCREEN_WIDTH, flex:1}}>
{this.state.elements.map((item, key) => {
return (
<Draggable
onDragRelease={(e,g,b) => {
this.dragNode(item, g.moveX, g.moveY)
} }
x={item.position_x}
y={item.position_y}
z={1000}
......
dragNode = (node, newX, newY) => {
var elements = this.state.elements
var newNode = node
//REMOVE THE NODE
var newElements = elements.filter(item2 => item2.id != node.id)
//EDIT POSITIONS
newNode.position_x = newX
newNode.position_y = newY
//PUSH NEW ONE
console.log(newNode)
newElements.push(newNode)
//SET AS STATE
this.setState({elements:newElements})
}
Its not working properly this way, going crazy and draggable places some irrevelant places
I think as you know better the problem is g.moveX is returning touch positions. But i want to get latest position of draggable after drag. Draggable works smooth, I just want to pass latest positions to state to store them.
Thanks for your support
Metadata
Metadata
Assignees
Labels
No labels