# ScalingLazyListState

Artifact: [androidx.wear.compose:compose-foundation](https://developer.android.com/jetpack/androidx/releases/wear-compose) [View Source](https://cs.android.com/search?q=file:androidx/wear/compose/foundation/lazy/ScalingLazyListState.kt+class:androidx.wear.compose.foundation.lazy.ScalingLazyListState) Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-compose#1.2.0)

<br />

```
class ScalingLazyListState : ScrollableState
```

<br />

*** ** * ** ***

A state object that can be hoisted to control and observe scrolling.

In most cases, this will be created via `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/rememberScalingLazyListState.composable#rememberScalingLazyListState(kotlin.Int,kotlin.Int)`.

## Summary

| ### Public companion properties |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/Saver<https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>` | `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#Saver()` The default `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#Saver()` implementation for `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState`. |

| ### Public constructors |
|---|
| `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/annotation/RememberInComposition https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#ScalingLazyListState(kotlin.Int,kotlin.Int)( initialCenterItemIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, initialCenterItemScrollOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` |

| ### Public functions |
|---|---|
| `suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#animateScrollToItem(kotlin.Int,kotlin.Int)(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, scrollOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Animate (smooth scroll) the given item at `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#animateScrollToItem(kotlin.Int,kotlin.Int)` to the center of the viewport and position it based on the `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState.Configuration#anchorType()` and applies the `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#animateScrollToItem(kotlin.Int,kotlin.Int)` pixels. |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#dispatchRawDelta(kotlin.Float)(delta: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` |
| `open suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#scroll(androidx.compose.foundation.MutatePriority,kotlin.coroutines.SuspendFunction1)(scrollPriority: https://developer.android.com/reference/kotlin/androidx/compose/foundation/MutatePriority, block: suspend https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/ScrollScope.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` |
| `suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#scrollToItem(kotlin.Int,kotlin.Int)(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, scrollOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Instantly brings the item at `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#scrollToItem(kotlin.Int,kotlin.Int)` to the center of the viewport and positions it based on the `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState.Configuration#anchorType()` and applies the `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#scrollToItem(kotlin.Int,kotlin.Int)` pixels. |

| ### Public properties |
|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#canScrollBackward()` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#canScrollForward()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#centerItemIndex()` The index of the item positioned closest to the viewport center |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#centerItemScrollOffset()` The offset of the item closest to the viewport center. |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#isScrollInProgress()` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#lastScrolledBackward()` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#lastScrolledForward()` |
| `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListLayoutInfo` | `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#layoutInfo()` The object of `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListLayoutInfo` calculated during the last layout pass. |

### Inherited properties

From [androidx.compose.foundation.gestures.ScrollableState](https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/ScrollableState) `open https://developer.android.com/reference/kotlin/androidx/compose/foundation/ScrollIndicatorState?` `https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/ScrollableState#scrollIndicatorState()`

## Public companion properties

### Saver

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-compose#1.2.0)

```
val Saver: Saver<ScalingLazyListState, Any>
```

The default `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#Saver()` implementation for `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState`.

## Public constructors

### ScalingLazyListState

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-compose#1.2.0)

```
@RememberInComposition
ScalingLazyListState(
    initialCenterItemIndex: Int = 1,
    initialCenterItemScrollOffset: Int = 0
)
```

| Parameters |
|---|---|
| `initialCenterItemIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html = 1` | the initial value for `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#centerItemIndex()`, defaults to 1. This will place the 2nd list item (index == 1) in the center of the viewport and the first item (index == 0) before it. If the developer wants custom control over position and spacing they can switch off autoCentering and provide contentPadding. |
| `initialCenterItemScrollOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html = 0` | the initial value for `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#centerItemScrollOffset()` Note that it is not always possible for the values provided by `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#initialCenterItemIndex()` and `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#initialCenterItemScrollOffset()` to be honored, e.g. If `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#initialCenterItemIndex()` is set to a value larger than the number of items initially in the list, or to an index that can not be placed in the middle of the screen due to the contentPadding or autoCentering properties provided to the `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyColumn.composable#ScalingLazyColumn(androidx.compose.ui.Modifier,androidx.wear.compose.foundation.lazy.ScalingLazyListState,androidx.compose.foundation.layout.PaddingValues,kotlin.Boolean,androidx.compose.foundation.layout.Arrangement.Vertical,androidx.compose.ui.Alignment.Horizontal,androidx.compose.foundation.gestures.FlingBehavior,kotlin.Boolean,androidx.wear.compose.foundation.lazy.ScalingParams,androidx.wear.compose.foundation.lazy.ScalingLazyListAnchorType,androidx.wear.compose.foundation.lazy.AutoCenteringParams,androidx.wear.compose.foundation.rotary.RotaryScrollableBehavior,androidx.compose.foundation.OverscrollEffect,kotlin.Function1)`. After the `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyColumn.composable#ScalingLazyColumn(androidx.compose.ui.Modifier,androidx.wear.compose.foundation.lazy.ScalingLazyListState,androidx.compose.foundation.layout.PaddingValues,kotlin.Boolean,androidx.compose.foundation.layout.Arrangement.Vertical,androidx.compose.ui.Alignment.Horizontal,androidx.compose.foundation.gestures.FlingBehavior,kotlin.Boolean,androidx.wear.compose.foundation.lazy.ScalingParams,androidx.wear.compose.foundation.lazy.ScalingLazyListAnchorType,androidx.wear.compose.foundation.lazy.AutoCenteringParams,androidx.wear.compose.foundation.rotary.RotaryScrollableBehavior,androidx.compose.foundation.OverscrollEffect,kotlin.Function1)` is initially drawn the actual values for the `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#centerItemIndex()` and `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#centerItemScrollOffset()` can be read from the state. |

## Public functions

### animateScrollToItem

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-compose#1.2.0)

```
suspend fun animateScrollToItem(index: Int, scrollOffset: Int = 0): Unit
```

Animate (smooth scroll) the given item at `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#animateScrollToItem(kotlin.Int,kotlin.Int)` to the center of the viewport and position it based on the `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState.Configuration#anchorType()` and applies the `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#animateScrollToItem(kotlin.Int,kotlin.Int)` pixels.

| Parameters |
|---|---|
| `index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the index to which to scroll. Must be non-negative. |
| `scrollOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html = 0` | the offset that the item should end up after the scroll (same as `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#scrollToItem(kotlin.Int,kotlin.Int)`) - note that positive offset refers to forward scroll, so in a top-to-bottom list, positive offset will scroll the item further upward (taking it partly offscreen) |

### dispatchRawDelta

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-compose#1.2.0)

```
open fun dispatchRawDelta(delta: Float): Float
```

### scroll

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-compose#1.2.0)

```
open suspend fun scroll(scrollPriority: MutatePriority, block: suspend ScrollScope.() -> Unit): Unit
```

### scrollToItem

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-compose#1.2.0)

```
suspend fun scrollToItem(index: Int, scrollOffset: Int = 0): Unit
```

Instantly brings the item at `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#scrollToItem(kotlin.Int,kotlin.Int)` to the center of the viewport and positions it based on the `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState.Configuration#anchorType()` and applies the `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListState#scrollToItem(kotlin.Int,kotlin.Int)` pixels.

| Parameters |
|---|---|
| `index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the index to which to scroll. Must be non-negative. |
| `scrollOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html = 0` | the offset that the item should end up after the scroll. Note that positive offset refers to forward scroll, so in a top-to-bottom list, positive offset will scroll the item further upward (taking it partly offscreen). |

## Public properties

### canScrollBackward

```
open val canScrollBackward: Boolean
```

### canScrollForward

```
open val canScrollForward: Boolean
```

### centerItemIndex

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-compose#1.2.0)

```
val centerItemIndex: Int
```

The index of the item positioned closest to the viewport center

### centerItemScrollOffset

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-compose#1.2.0)

```
val centerItemScrollOffset: Int
```

The offset of the item closest to the viewport center. Depending on the `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListAnchorType` of the `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyColumn.composable#ScalingLazyColumn(androidx.compose.ui.Modifier,androidx.wear.compose.foundation.lazy.ScalingLazyListState,androidx.compose.foundation.layout.PaddingValues,kotlin.Boolean,androidx.compose.foundation.layout.Arrangement.Vertical,androidx.compose.ui.Alignment.Horizontal,androidx.compose.foundation.gestures.FlingBehavior,kotlin.Boolean,androidx.wear.compose.foundation.lazy.ScalingParams,androidx.wear.compose.foundation.lazy.ScalingLazyListAnchorType,androidx.wear.compose.foundation.lazy.AutoCenteringParams,androidx.wear.compose.foundation.rotary.RotaryScrollableBehavior,androidx.compose.foundation.OverscrollEffect,kotlin.Function1)` the offset will be relative to either the items Edge or Center.

A positive value indicates that the center item's anchor point is above the viewport center-line, a negative value indicates that the center item anchor point is below the viewport center-line.

### isScrollInProgress

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-compose#1.2.0)

```
open val isScrollInProgress: Boolean
```

### lastScrolledBackward

```
open val lastScrolledBackward: Boolean
```

### lastScrolledForward

```
open val lastScrolledForward: Boolean
```

### layoutInfo

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-compose#1.2.0)

```
val layoutInfo: ScalingLazyListLayoutInfo
```

The object of `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/lazy/ScalingLazyListLayoutInfo` calculated during the last layout pass. For example, you can use it to calculate what items are currently visible.