Get position of Gui Element inside of a ScrollingFrame using UIListLayout

Hey, do someone know how to get the position of a gui element within a ScrollingFrame when using UIListLayout?

I’m making a plugin (here it is), as you can see, it has a sidebar with different categories. When a user click on a category, I would like the scrollingFrame to scroll to the first block of the category selected.

a kind of ScrollingFrame:ScrollTo(GuiObject)

thank you for your help!

Best way to do this that I can think of is to manually observe where the scroll frame should be positioned when click each button. Then you can create an attribute inside each button telling the location where the scroll frame should be. When the button is clicked, configure the CanvasPosition of the frame.

1 Like

Thank you for your help!
I will use that if there is not any other solution, but are you sure that there is not any function that allow you scrolling to an object? It would be a lot easier because I have planned to update the elements on a database. If I do this, I will have to manually change each value each time I add an element…

1 Like

I believe that if you add another section downwards, it will not really affect the position of the frame since it uses the offset, not the scale. Unless you switch the position between two sections that you already made, that then, you will have to configure it again.

yes, I will add sections between the other sections or add blocks to some sections, so that will affect the entire system… do you thing that if observe the position of the last item of the scrollingFrame and then divid this position by the count of items in total, I will get the offset used by one item? If yes, I will be able to calculate the offset position of the first item of each section each time the currentSection changes

1 Like

Yes of course. If there is no really function that can help you with this (I’m also sad), then using math to calculate the position would be a really great idea, you can use for loop to count how many elements inside each section and do some math calculations from there.

1 Like

I will do some research on how to do this more efficiently, and I will come back to this post if I find anything useful.

1 Like

Okay ! thank you very much for your precious help!

1 Like

You are very welcome! Enjoy coding!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.