ScrollController

A ScrollController is specially written to control Framer's Scroll component.

OptionTypeDefaultValueDescription
throttlenumber150Optional - How often to update the controller's state.
PropertyTypeDescription
scrollXnumberThe controller's current scroll position on the x axis.
scrollYnumberThe controller's current scroll position on the y axis.
scrollPoint{x: number, y: number}A normalized value, 0 when the current page is the pager's first page and 1 when the current page is the pager's last page.
direction{x: string, y: string}A point with either "left", "right", "none" for x, and "up", "down", or "none" for y.
progress{x: number, y: number}Normalized values for each scroll axis. For progress.x, a value of 0 is full left and 1 is full right; for progress.y, a value of 0 is full top and 1 is full bottom.
markersMarker[]A stateful object containing data about each tracked marker Frame.
contentReact.ElementThe connected Scroll component's content frame.
contentOffsetobjectThe contentOffsetX and contentOffsetY values, for controlling a Scroll component's scroll position.
MethodDescription
handleScroll(point: {x: number, y: number})Update the scroll controller using a point. Often, this is connected to a Scroll component's onMove callback.
scrollToPoint(point: {x: number, y: number}, options)Change the page left or right.
scrollToMarker(id: string, edges: string or string[], offset: number, options)Scroll to a given marker, edge, with an offset and animation options.
getMarker(props)Get the current marker entry from a given set of Override props.

Markers

The ScrollController will keep track of certain Frames, referred to here as "markers". Markers are recognized automatically. A marker must be a child of the controller's connected scroll component's content, and may be a design component with an override prop named "markerId" (most often, this will be a hidden or opacity zero text layer, ticked to be overridable) or may be a code component with a markerId prop.

For each markers, an entry is made in the controller.markers. In the case of design component markers, the marker's property name will be the props.id of the design component instance, automatically generated by Framer X. If a marker is code component, its property name will be the value of its props.markerId. For example, a design component's entry may be found at controller.markers.id_kukhbjalsdc, whereas a code component's entry may be found at controller.markers.myMarker.

Each marker's entry has the following stateful properties.

PropertyDescription
absoluteThe marker's absolute position within the content Frame.
offsetThe marker's position relative to the Scroll component's frame.
progressThe marker's progress through the Scroll component's frame. A marker's progress will be {x: 0, y: 0} when it is below and to the right of the frame and {x: 1, y: 1} when it is above and to the left of the frame.
intersectA point with normalized x and y properties describing how much of the marker is currently in view.
clipA point describing which edges of the marker are clipped, or out of the Scroll component's current window. For x, a marker's clip state may be "none", "both", "both-left", "both-right", "left", or "right". For y, a marker's clip state may be "none", "both", "both-top", "both-bottom", "top", or "bottom".
visibleWhether the marker is at all visible in the Scroll component's current window.

Example: