-
- All Implemented Interfaces:
-
com.google.android.horologist.compose.rotaryinput.RotarySnapBehavior
public final class DefaultSnapBehavior implements RotarySnapBehavior
An animated implementation of RotarySnapBehavior. Uses animateScrollToItem method for snapping to the Nth item
-
-
Constructor Summary
Constructors Constructor Description DefaultSnapBehavior(RotaryScrollAdapter rotaryScrollAdapter, SnapParameters snapParameters)
-
Method Summary
Modifier and Type Method Description UnitprepareSnapForItems(Integer moveForElements, Boolean sequentialSnap)Preparing snapping. UnitstartSnappingSession(Boolean toClosestItem)Performs snapping to the specified in prepareSnapForItems element If toClosestItem is true - then the snapping will happen to the closest item only. FloatsnapThreshold(Boolean duringSnap)A threshold after which snapping happens. -
-
Constructor Detail
-
DefaultSnapBehavior
DefaultSnapBehavior(RotaryScrollAdapter rotaryScrollAdapter, SnapParameters snapParameters)
-
-
Method Detail
-
prepareSnapForItems
Unit prepareSnapForItems(Integer moveForElements, Boolean sequentialSnap)
Preparing snapping. This method should be called before startSnappingSession is called.
Snapping is done for current + moveForElements items.
If sequentialSnap is true, items are summed up together. For example, if prepareSnapForItems is called with moveForElements = 2, 3, 5 -> then the snapping will happen to current + 10 items
If sequentialSnap is false, then moveForElements are not summed up together.
-
startSnappingSession
Unit startSnappingSession(Boolean toClosestItem)
Performs snapping to the specified in prepareSnapForItems element If toClosestItem is true - then the snapping will happen to the closest item only. If it's set to false - then it'll snap to the element specified in prepareSnapForItems method.
-
snapThreshold
Float snapThreshold(Boolean duringSnap)
A threshold after which snapping happens. There can be 2 thresholds - before snap and during snap (while snap is happening ). During-snap threshold is usually longer than before-snap so that the list will not scroll too fast.
-
-
-
-