Moving VisualElement slow?

As I gather, moving a single VisualElement will cause every child element to recalculate it’s transform, or something like that, according to the Profiler. Either way, my inventory screen is very slow to move and resize. I have no idea how to fix, is there a special way to move things without causing the whole hierarchy to recalculate?
Moving is done with:

            CurrentlyDragging.style.left = V.x / scale;
            CurrentlyDragging.style.top = V.y / scale;

Resize is done with:

            CurrentlyDragging.style.width = V.x / scale;
            CurrentlyDragging.style.height = V.y / scale;

Moving elements without having to invalidate the style and layout can be done with visualElement.transform.position, which will be way faster.

If it’s an operation that occurs frequently or if the moved element has a lot of children, you can experiment with usageHints to change the way the end geometry is generated:

1 Like

Performance got way better just from changing the usageHints. I didn’t see a big difference on using visualElement.transform.position, but that was after changing the usageHints, so usageHints is probably much more important.