Reposition element after render

Is there a way to know when an element has finished resizing so that it can be conditionally positioned?
I need to display a dynamic tooltip (a custom VisualElement) on top of an item, but before displaying I need to measure the tooltip height to make sure it fits in the available space.
My current solution is:

tooltip.style.opacity = 0;
tooltip.Show();
tooltip.Render(Data);
tooltip.schedule.Execute(() => {
    tooltip.SetPosition(worldBound);
    tooltip.style.opacity = 1;
}).ExecuteLater(1);

It works but sometimes there’s a flicker
Is there a better way?

Thanks

I believe GeometryChangedEvent what you are looking for.

Also, is it for editor or runtime? If you are looking for runtime, you could try AppUI which has built-in tooltip feature. It’s also works in editor too.

1 Like

From my tests GeometryChanged doesn’t trigger when the element is hidden
It’s for runtime and I cannot use anything external (the package is for the unity asset store)