Focus onto an element within a scrolling frame?

I am wondering if this is possible to be coded and if so, how should I go about it

Ex: I want to focus in on a particular element within a large group of elements in a scrolling frame, I would like to be able for a button on click to automatically move the scroll bar into a position where the target element is in view

1 Like

Scrolling frame has an attribute called CanvasPosition which essentially determines the position of the scrollbar. It is a offset value, not a scale value. So by getting the absolute size of the scrolling frame and the size of your target element you can just calculate the CanvasPosition offset you desire.

This will do it:
scrollingFrame.CanvasPosition = Vector2.new(0,scrollingFrame.AbsoluteCanvasSize.Y * target.Position.Y.Scale + target.AbsoluteSize.Y/2 - scrollingFrame.AbsoluteSize.Y/2)

8 Likes

I will test it out when I am able to–thanks for your help

1 Like