ScrollAnchorRole
A type defining the role of a scroll anchor.
Declaration
type ScrollAnchorRole = 'alignment' | 'initialOffset' | 'sizeChanges';struct ScrollAnchorRolePass a literal, or build one with SwiftUI.ScrollAnchorRole from import { SwiftUI } from 'swiftui-react-native'.
Type properties
'alignment'SwiftUI.ScrollAnchorRole.alignmentThe role that influences how a scroll view should align its content when the size of its content is smaller than the container size of the scroll view.
'initialOffset'SwiftUI.ScrollAnchorRole.initialOffsetThe role that influences where a scroll view should be initially scrolled.
'sizeChanges'SwiftUI.ScrollAnchorRole.sizeChangesThe role that influences how a scroll view should adjust its content offset when the scroll view's content or container size changes.
Overview
You can associate a UnitPoint to a ScrollView using the
View.defaultScrollAnchor(_:) modifier. By default, the system
uses this point for different kinds of behaviors including:
- Where the scroll view should initially be scrolled
- How the scroll view should handle content size or container size changes
- How the scroll view should align content smaller than its container size
You can further customize this behavior by assigning different unit points for these different roles.
From Apple’s SwiftUI documentation. Code samples there are Swift.
Used by
See also
More in Layout.
- AlignmentAn alignment in both axes.
- ContainerBackgroundPlacementThe placement of a container background.
- ContainerValuesReadableKeys of SwiftUI ContainerValues JavaScript can read.
- ContainerValuesWritableKeys of SwiftUI ContainerValues JavaScript can write.
- ControlSizeThe size classes, like regular or small, that you can apply to controls within a view.
- DocumentLaunchGeometryProxyA proxy for access to the frame of the scene and its title view.
- DynamicTypeSizeA Dynamic Type size, which specifies how large scalable content should be.
- EdgeAn enumeration to indicate one edge of a rectangle.
- EdgeInsetsThe inset distances for the sides of a rectangle.
- EdgeInsetsChainEdgeInsets with chained calls: SwiftUI.EdgeInsets.inset(...).
- EdgeSetAn efficient set of edges.
- GeometryProxyA proxy for access to the size and coordinate space (for anchor resolution) of the container view.