-
Hello there! I was taking a look at the position.rs example and was wondering if there is an easy way to get the current position of some component so that I could move it relative to its current location. The view component can be identified using its name or its LayerPosition directly. From what I could tell by looking at struct StackView, only the position of the topmost element can be retrieved by using offset(). So, is there an easy way I have just overlooked? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, and thanks for the question! "Current position" can be a bit ambiguous:
What matters to you will depend on your use-case. You say you want to "move [a view] relative to its current location". Is the view currently a layer by itself in a If your view is currently a standalone layer, it's indeed easier to move around without affecting other views. In that case, the absolute offset of the view is what you need. As you noticed, one way to get that is EDIT: I just added this One time when the position is made available is when drawing the view. The This currently ignores any scrolling parent, but you don't care about that if your view is directly a layer from the |
Beta Was this translation helpful? Give feedback.
Hi, and thanks for the question!
"Current position" can be a bit ambiguous:
ScrollView
for example. In such a situation, the wrapped view origin could be above and to the left of the terminal, but only a subset of the view would actually be visible.