Page 1 of 1

Problem with "attachtonewparent"

Posted: 15 July 2021, 23:12
by Badguizmo
Hello.

I am facing a problem when using "attachtonewparent".
In the Studio doc it is specified that "With this method, you change the HTML parent of "mobile_obj" element. "target_obj" is the new parent of this element. The beauty of attachToNewParent is that the mobile_obj element DOES NOT MOVE during this process."
But when using it my object in moving, apparenl=tly for 7px (10% the size of my square).

I have used this function in a precedent game and there was no pb.
What can cause this strange behavior ? I have tried different combination on the "absolute or relative" positions but it does not seem to change anything.

NB : the studio project is "Badguizmotestun".

Thank you all for your clues ;)

Re: Problem with "attachtonewparent"

Posted: 16 July 2021, 02:35
by paramesis
Do you have a CSS transform applied to either parent element? attachToNewParent uses dojo.position, similar to placeOnObjectPos and slideToObjectPos, which produce unexpected results when CSS transforms are involved. See this post for more info:

https://boardgamearena.com/forum/viewto ... 189#p51274

Re: Problem with "attachtonewparent"

Posted: 16 July 2021, 10:59
by Badguizmo
paramesis wrote: 16 July 2021, 02:35 Do you have a CSS transform applied to either parent element? attachToNewParent uses dojo.position, similar to placeOnObjectPos and slideToObjectPos, which produce unexpected results when CSS transforms are involved. See this post for more info:

https://boardgamearena.com/forum/viewto ... 189#p51274
Hello.

I saw this thread before. Maybe

The only CSS transform I am doing is when hovering :

Code: Select all

.square-possible-selection:hover {
    transform: scale(1.1);
    z-index: 100; 
}
When desactivating it, apparently my problem is solved.
Now I have to deal with this. I will try to remove the class before moving the element ;)

But maybe I was doing this in my previous game code, that is why I passed trought this behaviour :oops: :oops: :oops:

Re: Problem with "attachtonewparent"

Posted: 18 July 2021, 17:49
by Galeelox
You can set a scale of 1, then attach to new parent, and set the scale to 1.1.
It's so quick that you can't notice it.