X,y Coordinates of Rotated Object Are Wrong


#1

I need to know the x,y position of a rectangle that can be rotated to any angle. It would appear that Axure returns the x,y of the rectangle as if it hasn’t been rotated. One effect is that drag/drop no longer works on the rotated rectangle.

Simple file attached. Drag/drop the black square onto the purple rectangle - it aligns happily to the left. Click the purple rectangle to rotate it clockwise 30degs anchored right (you can do this multiple times). A ‘shadow’ rectangle is moved to the new x,y coordinates of the purple rectangle. Dragging/dropping the black square now only works if it’s over the shadow rectangle not the purple and it will align with the shadow rectangle instead of the purple.

It would seem that Axure draws the purple rectangle based on a combination of the horizontal x/y plus the rotation but when you ask for the x,y it returns just the horizontal element.

20230424 Drag Drop Rotate Error.rp (66.1 KB)


#2

You are correct that Axure retains the bounding box of the original element, but this can be overcome with clever engineering. What is it you’d like the draggable widget to do?


#3

Thanks for the response. This is a demo file that uses a ‘balance’ with boxes that can be drag/dropped onto any of six positions, three on either side of the balance. In the ‘real’ app, dropping a box onto the balance causes it to rotate according to the weight but in order to focus on this issue I have provided buttons that rotate the scale manually. Also, only the two leftmost positions (they are dynamic panels - drop panels) on the balance are active; the others are grayed out.

In order to rotate the balance correctly I need to know on which drop panel the black box has been dropped and, because of this issue, I can’t do this if the balance has been rotated.

With the balance level, if you drag/drop the black box onto one of the two balance positions it appears to snap correctly into place. What actually happens is that the black box is first moved to the X,Y position of the drop panel and rotated to the same angle as the balance (in this case zero) and then hidden and the drop panel is set to a black state. You can restore the black box to its start position using the button.

If you rotate the balance and try to drop the black box onto one of the drop panels you can’t, because the ‘if area of A is over B’ test fails because the X,Y co-ordinates of the drop panel are those of the ‘original bounding box’. I have added two empty boxes at the original X,Y positions of the drop panels. In order to drop the black box on to the balance you have actually to drop it onto the area of one of the empty boxes because that’s where Axure thinks the drop panels are. If you click ‘Show Black’ you can see by its position that this is the case.

So… what is the ‘clever engineering’ to get round this and - more intriguingly - what is the thinking behind this anomally?
20230423 Drag Drop Test.rp (95.9 KB)