Hi, I’m building a draggable component to drag an item from one section to another in the gui. i make a drag proxy on down, follow the mouse, and then drop it on up. to make the drag proxy i clone the control. the gui also has an ideal width set. when the component is cloned and then added back into the scene it doesn’t respect the ideal width. it seems like it is applied twice? once on serialize and again when place back in? i don’t really know whats happening underneath the hood to be honest.
I do have a playground showing the issue:
for now i have to resize all the properties of the clone and its children again, which at that point i might as well not use clone and just use a factory to build the surrogate. if its unavoidable please let me know and i’ll make myself that factory =D
This is because when cloning we serialize and then parse but due to the idealWidth when getting width back, we get the adapted one → 548px instead of 150. Unfortunately the fix is not straightforward and I would prefer @RaananW to have a look after the break.
In the meantime, your factory idea will be perfect.
This is a matter of order of operations. Here, this works:
When you set the idealWidth of the ADT, the width value changes. If you debug the values when you set the idealWidth before cloning you will notice that the actual width value is higher than 150px. Setting the idealWidth after cloning fixes the issue.
Now to the real issue - we serialize the width using the modified value and not the original value, which is probably not the best approach. I will keep it assigned to me to see if we can use other values for serialization, or compensate correctly when serializing. Thanks for reporting this!