Page 2 of 2

Re: dragging a rotated element

Posted: 02 February 2021, 14:26
by Victoria_La
I remember few games, but I am not sure if they have drag though. Kingdomino and Isaac, in issac it does not really drag but it follow mouse coursor rotated, I still don't see how it won't work if you use vanila js/html stuff except is transform is used during drag as well (and it does not stack)
What is you game name - I can clone it to look

Re: dragging a rotated element

Posted: 02 February 2021, 14:28
by galehar
It's race for the galaxy, but the access is restricted. However, as I've just mentioned, Steam Works features the same bug.

Re: dragging a rotated element

Posted: 02 February 2021, 16:44
by shadowphiar
galehar wrote: 02 February 2021, 12:15
shadowphiar wrote: 02 February 2021, 10:58 You can drag rotated elements in Steam Works (although its fairly rare - only a couple of tiles ever rotate). I didn't have any similar problem with rotated elements disappearing and didn't do anything special to counter it ¯\_(ツ)_/¯ (the code uses draggable, but if you look at it beware I had to customise it quite severely to cope with some z-ordering issues.)
Have you tried it in chrome? I just did, and you have the exact same bug as I do. Once the tile is rotated, if you try to drag it, it disappears.
Oh! I'd better have a look at that then. (Development was mostly in Safari, with some Firefox, Chrome and Edge for testing, but perhaps I never did that particular operation in that browser. As I said, it's fairly rare). I'll let you know if I discover anything helpful.

Re: dragging a rotated element

Posted: 03 February 2021, 02:20
by Victoria_La
I found a bug in draggable which is currently only exists in studio deployed code, I sent email to admins, stay tunned.

Re: dragging a rotated element

Posted: 05 February 2021, 01:04
by shadowphiar
Yes... during onMouseDown it's trying to work out whether this element (or its parents) is being zoomed in by a css transformation, but its method of doing this is naive at best.

As a workaround until the underlying bug is fixed, it appears to be safe to set

Code: Select all

this.zoomFactorOriginalElement = 1;
inside your onStartDragging function, unless you're actually using css zooming on that element in which case you might have to adjust for that. Note though that the zooming of the whole interface which is applied automatically to small windows, doesn't have to be accounted for here as this function is only looking at parent elements up to `game_play_area`)

Re: dragging a rotated element

Posted: 05 February 2021, 09:27
by Een
Victoria_La wrote: 03 February 2021, 02:20 I found a bug in draggable which is currently only exists in studio deployed code, I sent email to admins, stay tunned.
I have used Victoria_La's proposal for a quick workaround on this, and pushed a new version on the studio (not in prod).
I tested quickly locally, but I didn't write this component and I'm not completely sure about the usecase. So please let me know if it solves the issue referenced in this thread (and doesn't break anything).

Re: dragging a rotated element

Posted: 05 February 2021, 11:41
by shadowphiar
Hi Een, yes I think the change works and would be safe for any rotation, scale or translate transform.

Re: dragging a rotated element

Posted: 05 February 2021, 11:43
by Een
shadowphiar wrote: 05 February 2021, 11:41 Hi Een, yes I think the change works and would be safe for any rotation, scale or translate transform.
Thanks! Then it will be included in our next release.

Re: dragging a rotated element

Posted: 05 February 2021, 11:53
by galehar
Thanks Een!
Same here, it does fix the bug and I haven't seen any issue.
Is there a date for the next release? Because there is a workaround and I'm wondering if I should bother releasing it in prod.

Re: dragging a rotated element

Posted: 05 February 2021, 12:16
by Een
galehar wrote: 05 February 2021, 11:53 Thanks Een!
Same here, it does fix the bug and I haven't seen any issue.
Is there a date for the next release? Because there is a workaround and I'm wondering if I should bother releasing it in prod.
Usually once per week (but not a golden rule). Next one most likely next Thursday.
(and thanks should go mostly to Victoria_La ;) )