blob: 86c7c45cf8a9dadc73e1360237c8d599783d3462 [file] [log] [blame]
<html devsite="true">
<head>
<title>SwipeableState</title>
{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %}
{% include "_shared/_reference-head-tags.html" %}
</head>
<body>
<div id="metadata-info-block"></div>
<h1>SwipeableState</h1>
<p>
<pre>@<a href="/reference/androidx/compose/material/ExperimentalMaterialApi.html">ExperimentalMaterialApi</a><br>public class <a href="/reference/androidx/compose/material/SwipeableState.html">SwipeableState</a>&lt;T&nbsp;extends&nbsp;<a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>&gt;</pre>
</p>
<div class="devsite-table-wrapper"><devsite-expandable><span class="expand-control jd-sumtable-subclasses">Known direct subclasses
<div class="showalways" id="subclasses-direct"><a href="/reference/androidx/compose/material/BackdropScaffoldState.html">BackdropScaffoldState</a>, <a href="/reference/androidx/compose/material/BottomDrawerState.html">BottomDrawerState</a>, <a href="/reference/androidx/compose/material/BottomSheetState.html">BottomSheetState</a>, <a href="/reference/androidx/compose/material/DismissState.html">DismissState</a>, <a href="/reference/androidx/compose/material/ModalBottomSheetState.html">ModalBottomSheetState</a></div>
</span>
<div id="subclasses-direct-summary">
<div class="devsite-table-wrapper">
<table class="responsive">
<colgroup>
<col width="40%">
<col>
</colgroup>
<tbody class="list">
<tr>
<td width="40%"><code><a href="/reference/androidx/compose/material/BackdropScaffoldState.html">BackdropScaffoldState</a></code></td>
<td>
<p>State of the <code><a href="/reference/androidx/compose/material/package-summary.html#BackdropScaffold(kotlin.Function0,kotlin.Function0,kotlin.Function0,androidx.compose.ui.Modifier,androidx.compose.material.BackdropScaffoldState,kotlin.Boolean,androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp,kotlin.Boolean,kotlin.Boolean,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Shape,androidx.compose.ui.unit.Dp,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,kotlin.Function1)">BackdropScaffold</a></code> composable.</p>
</td>
</tr>
<tr>
<td width="40%"><code><a href="/reference/androidx/compose/material/BottomDrawerState.html">BottomDrawerState</a></code></td>
<td>
<p>State of the <code><a href="/reference/androidx/compose/material/package-summary.html#BottomDrawer(kotlin.Function1,androidx.compose.ui.Modifier,androidx.compose.material.BottomDrawerState,kotlin.Boolean,androidx.compose.ui.graphics.Shape,androidx.compose.ui.unit.Dp,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,kotlin.Function0)">BottomDrawer</a></code> composable.</p>
</td>
</tr>
<tr>
<td width="40%"><code><a href="/reference/androidx/compose/material/BottomSheetState.html">BottomSheetState</a></code></td>
<td>
<p>State of the persistent bottom sheet in <code><a href="/reference/androidx/compose/material/package-summary.html#BottomSheetScaffold(kotlin.Function1,androidx.compose.ui.Modifier,androidx.compose.material.BottomSheetScaffoldState,kotlin.Function0,kotlin.Function1,kotlin.Function0,androidx.compose.material.FabPosition,kotlin.Boolean,androidx.compose.ui.graphics.Shape,androidx.compose.ui.unit.Dp,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.ui.unit.Dp,kotlin.Function1,kotlin.Boolean,androidx.compose.ui.graphics.Shape,androidx.compose.ui.unit.Dp,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,kotlin.Function1)">BottomSheetScaffold</a></code>.</p>
</td>
</tr>
<tr>
<td width="40%"><code><a href="/reference/androidx/compose/material/DismissState.html">DismissState</a></code></td>
<td>
<p>State of the <code><a href="/reference/androidx/compose/material/package-summary.html#SwipeToDismiss(androidx.compose.material.DismissState,androidx.compose.ui.Modifier,kotlin.collections.Set,kotlin.Function1,kotlin.Function1,kotlin.Function1)">SwipeToDismiss</a></code> composable.</p>
</td>
</tr>
<tr>
<td width="40%"><code><a href="/reference/androidx/compose/material/ModalBottomSheetState.html">ModalBottomSheetState</a></code></td>
<td>
<p>State of the <code><a href="/reference/androidx/compose/material/package-summary.html#ModalBottomSheetLayout(kotlin.Function1,androidx.compose.ui.Modifier,androidx.compose.material.ModalBottomSheetState,androidx.compose.ui.graphics.Shape,androidx.compose.ui.unit.Dp,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,kotlin.Function0)">ModalBottomSheetLayout</a></code> composable.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</devsite-expandable> </div>
<hr>
<p>State of the <code><a href="/reference/androidx/compose/material/package-summary.html#(androidx.compose.ui.Modifier).swipeable(androidx.compose.material.SwipeableState,kotlin.collections.Map,androidx.compose.foundation.gestures.Orientation,kotlin.Boolean,kotlin.Boolean,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Function2,androidx.compose.material.ResistanceConfig,androidx.compose.ui.unit.Dp)">swipeable</a></code> modifier.</p>
<p>This contains necessary information about any ongoing swipe or animation and provides methods to change the state either immediately or by starting an animation. To create and remember a <code><a href="/reference/androidx/compose/material/SwipeableState.html">SwipeableState</a></code> with the default animation clock, use <code><a href="/reference/androidx/compose/material/package-summary.html#rememberSwipeableState(kotlin.Any,androidx.compose.animation.core.AnimationSpec,kotlin.Function1)">rememberSwipeableState</a></code>.</p>
<h2>Summary</h2>
<div class="devsite-table-wrapper">
<table class="responsive">
<colgroup>
<col width="40%">
<col>
</colgroup>
<thead>
<tr>
<th colspan="100%"><h3>Nested types</h3></th>
</tr>
</thead>
<tbody class="list">
<tr>
<td>
<div><code>public static class <a href="/reference/androidx/compose/material/SwipeableState.Companion.html">SwipeableState.Companion</a></code></div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<colgroup>
<col width="40%">
<col>
</colgroup>
<thead>
<tr>
<th colspan="100%"><h3>Public fields</h3></th>
</tr>
</thead>
<tbody class="list">
<tr>
<td width="40%"><code>final @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> T</code></td>
<td>
<div><code><a href="/reference/androidx/compose/material/SwipeableState.html#currentValue()">currentValue</a></code></div>
<p>The current value of the state.</p>
</td>
</tr>
<tr>
<td width="40%"><code>final float</code></td>
<td>
<div><code>@<a href="/reference/androidx/compose/material/ExperimentalMaterialApi.html">ExperimentalMaterialApi</a><br><a href="/reference/androidx/compose/material/SwipeableState.html#direction()">direction</a></code></div>
<p>The direction in which the <code><a href="/reference/androidx/compose/material/package-summary.html#(androidx.compose.ui.Modifier).swipeable(androidx.compose.material.SwipeableState,kotlin.collections.Map,androidx.compose.foundation.gestures.Orientation,kotlin.Boolean,kotlin.Boolean,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Function2,androidx.compose.material.ResistanceConfig,androidx.compose.ui.unit.Dp)">swipeable</a></code> is moving, relative to the current <code><a href="/reference/androidx/compose/material/SwipeableState.html#currentValue()">currentValue</a></code>.</p>
</td>
</tr>
<tr>
<td width="40%"><code>final boolean</code></td>
<td>
<div><code><a href="/reference/androidx/compose/material/SwipeableState.html#isAnimationRunning()">isAnimationRunning</a></code></div>
<p>Whether the state is currently animating.</p>
</td>
</tr>
<tr>
<td width="40%"><code>final @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/runtime/State.html">State</a>&lt;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/Float.html">Float</a>&gt;</code></td>
<td>
<div><code><a href="/reference/androidx/compose/material/SwipeableState.html#offset()">offset</a></code></div>
<p>The current position (in pixels) of the <code><a href="/reference/androidx/compose/material/package-summary.html#(androidx.compose.ui.Modifier).swipeable(androidx.compose.material.SwipeableState,kotlin.collections.Map,androidx.compose.foundation.gestures.Orientation,kotlin.Boolean,kotlin.Boolean,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Function2,androidx.compose.material.ResistanceConfig,androidx.compose.ui.unit.Dp)">swipeable</a></code>.</p>
</td>
</tr>
<tr>
<td width="40%"><code>final @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/runtime/State.html">State</a>&lt;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/Float.html">Float</a>&gt;</code></td>
<td>
<div><code><a href="/reference/androidx/compose/material/SwipeableState.html#overflow()">overflow</a></code></div>
<p>The amount by which the <code><a href="/reference/androidx/compose/material/package-summary.html#(androidx.compose.ui.Modifier).swipeable(androidx.compose.material.SwipeableState,kotlin.collections.Map,androidx.compose.foundation.gestures.Orientation,kotlin.Boolean,kotlin.Boolean,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Function2,androidx.compose.material.ResistanceConfig,androidx.compose.ui.unit.Dp)">swipeable</a></code> has been swiped past its bounds.</p>
</td>
</tr>
<tr>
<td width="40%"><code>final @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/material/SwipeProgress.html">SwipeProgress</a>&lt;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> T&gt;</code></td>
<td>
<div><code>@<a href="/reference/androidx/compose/material/ExperimentalMaterialApi.html">ExperimentalMaterialApi</a><br><a href="/reference/androidx/compose/material/SwipeableState.html#progress()">progress</a></code></div>
<p>Information about the ongoing swipe or animation, if any.</p>
</td>
</tr>
<tr>
<td width="40%"><code>final @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> T</code></td>
<td>
<div><code>@<a href="/reference/androidx/compose/material/ExperimentalMaterialApi.html">ExperimentalMaterialApi</a><br><a href="/reference/androidx/compose/material/SwipeableState.html#targetValue()">targetValue</a></code></div>
<p>The target value of the state.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<colgroup>
<col width="40%">
<col>
</colgroup>
<thead>
<tr>
<th colspan="100%"><h3>Public constructors</h3></th>
</tr>
</thead>
<tbody class="list">
<tr>
<td>
<div><code>&lt;T&nbsp;extends&nbsp;<a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>&gt; <a href="/reference/androidx/compose/material/SwipeableState.html#SwipeableState(kotlin.Any,androidx.compose.animation.core.AnimationSpec,kotlin.Function1)">SwipeableState</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> T&nbsp;initialValue,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/animation/core/AnimationSpec.html">AnimationSpec</a>&lt;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/Float.html">Float</a>&gt;&nbsp;animationSpec,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> Function1&lt;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> newValue,&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/Boolean.html">Boolean</a>&gt;&nbsp;confirmStateChange<br>)</code></div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<colgroup>
<col width="40%">
<col>
</colgroup>
<thead>
<tr>
<th colspan="100%"><h3>Public methods</h3></th>
</tr>
</thead>
<tbody class="list">
<tr>
<td width="40%"><code>final void</code></td>
<td>
<div><code>@<a href="/reference/androidx/compose/material/ExperimentalMaterialApi.html">ExperimentalMaterialApi</a><br><a href="/reference/androidx/compose/material/SwipeableState.html#animateTo(kotlin.Any,androidx.compose.animation.core.AnimationSpec)">animateTo</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> T&nbsp;targetValue,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/animation/core/AnimationSpec.html">AnimationSpec</a>&lt;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/Float.html">Float</a>&gt;&nbsp;anim<br>)</code></div>
<p>Set the state to the target value by starting an animation.</p>
</td>
</tr>
<tr>
<td width="40%"><code>final float</code></td>
<td>
<div><code><a href="/reference/androidx/compose/material/SwipeableState.html#performDrag(kotlin.Float)">performDrag</a>(float&nbsp;delta)</code></div>
<p>Force <code><a href="/reference/androidx/compose/material/package-summary.html#(androidx.compose.ui.Modifier).swipeable(androidx.compose.material.SwipeableState,kotlin.collections.Map,androidx.compose.foundation.gestures.Orientation,kotlin.Boolean,kotlin.Boolean,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Function2,androidx.compose.material.ResistanceConfig,androidx.compose.ui.unit.Dp)">swipeable</a></code> to consume drag delta provided from outside of the regular <code><a href="/reference/androidx/compose/material/package-summary.html#(androidx.compose.ui.Modifier).swipeable(androidx.compose.material.SwipeableState,kotlin.collections.Map,androidx.compose.foundation.gestures.Orientation,kotlin.Boolean,kotlin.Boolean,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Function2,androidx.compose.material.ResistanceConfig,androidx.compose.ui.unit.Dp)">swipeable</a></code> gesture flow.</p>
</td>
</tr>
<tr>
<td width="40%"><code>final void</code></td>
<td>
<div><code><a href="/reference/androidx/compose/material/SwipeableState.html#performFling(kotlin.Float)">performFling</a>(float&nbsp;velocity)</code></div>
<p>Perform fling with settling to one of the anchors which is determined by the given <code><a href="/reference/androidx/compose/material/SwipeableState.html#performFling(kotlin.Float)">velocity</a></code>.</p>
</td>
</tr>
<tr>
<td width="40%"><code>final void</code></td>
<td>
<div><code>@<a href="/reference/androidx/compose/material/ExperimentalMaterialApi.html">ExperimentalMaterialApi</a><br><a href="/reference/androidx/compose/material/SwipeableState.html#snapTo(kotlin.Any)">snapTo</a>(@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> T&nbsp;targetValue)</code></div>
<p>Set the state without any animation and suspend until it's set</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="list">
<h2>Public fields</h2>
<div class="api-item"><a name="getCurrentValue()"></a><a name="setCurrentValue()"></a><a name="getCurrentValue--"></a><a name="setCurrentValue--"></a>
<h3 class="api-name" id="currentValue()">currentValue</h3>
<pre class="api-signature no-pretty-print">public&nbsp;final&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> T&nbsp;<a href="/reference/androidx/compose/material/SwipeableState.html#currentValue()">currentValue</a></pre>
<p>The current value of the state.</p>
<p>If no swipe or animation is in progress, this corresponds to the anchor at which the <code><a href="/reference/androidx/compose/material/package-summary.html#(androidx.compose.ui.Modifier).swipeable(androidx.compose.material.SwipeableState,kotlin.collections.Map,androidx.compose.foundation.gestures.Orientation,kotlin.Boolean,kotlin.Boolean,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Function2,androidx.compose.material.ResistanceConfig,androidx.compose.ui.unit.Dp)">swipeable</a></code> is currently settled. If a swipe or animation is in progress, this corresponds the last anchor at which the <code><a href="/reference/androidx/compose/material/package-summary.html#(androidx.compose.ui.Modifier).swipeable(androidx.compose.material.SwipeableState,kotlin.collections.Map,androidx.compose.foundation.gestures.Orientation,kotlin.Boolean,kotlin.Boolean,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Function2,androidx.compose.material.ResistanceConfig,androidx.compose.ui.unit.Dp)">swipeable</a></code> was settled before the swipe or animation started.</p>
</div>
<div class="api-item"><a name="getDirection()"></a><a name="setDirection()"></a><a name="getDirection--"></a><a name="setDirection--"></a>
<h3 class="api-name" id="direction()">direction</h3>
<pre class="api-signature no-pretty-print">@<a href="/reference/androidx/compose/material/ExperimentalMaterialApi.html">ExperimentalMaterialApi</a><br>public&nbsp;final&nbsp;float&nbsp;<a href="/reference/androidx/compose/material/SwipeableState.html#direction()">direction</a></pre>
<p>The direction in which the <code><a href="/reference/androidx/compose/material/package-summary.html#(androidx.compose.ui.Modifier).swipeable(androidx.compose.material.SwipeableState,kotlin.collections.Map,androidx.compose.foundation.gestures.Orientation,kotlin.Boolean,kotlin.Boolean,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Function2,androidx.compose.material.ResistanceConfig,androidx.compose.ui.unit.Dp)">swipeable</a></code> is moving, relative to the current <code><a href="/reference/androidx/compose/material/SwipeableState.html#currentValue()">currentValue</a></code>.</p>
<p>This will be either 1f if it is is moving from left to right or top to bottom, -1f if it is moving from right to left or bottom to top, or 0f if no swipe or animation is in progress.</p>
</div>
<div class="api-item"><a name="getIsAnimationRunning()"></a><a name="setIsAnimationRunning()"></a><a name="getIsAnimationRunning--"></a><a name="setIsAnimationRunning--"></a>
<h3 class="api-name" id="isAnimationRunning()">isAnimationRunning</h3>
<pre class="api-signature no-pretty-print">public&nbsp;final&nbsp;boolean&nbsp;<a href="/reference/androidx/compose/material/SwipeableState.html#isAnimationRunning()">isAnimationRunning</a></pre>
<p>Whether the state is currently animating.</p>
</div>
<div class="api-item"><a name="getOffset()"></a><a name="setOffset()"></a><a name="getOffset--"></a><a name="setOffset--"></a>
<h3 class="api-name" id="offset()">offset</h3>
<pre class="api-signature no-pretty-print">public&nbsp;final&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/runtime/State.html">State</a>&lt;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/Float.html">Float</a>&gt;&nbsp;<a href="/reference/androidx/compose/material/SwipeableState.html#offset()">offset</a></pre>
<p>The current position (in pixels) of the <code><a href="/reference/androidx/compose/material/package-summary.html#(androidx.compose.ui.Modifier).swipeable(androidx.compose.material.SwipeableState,kotlin.collections.Map,androidx.compose.foundation.gestures.Orientation,kotlin.Boolean,kotlin.Boolean,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Function2,androidx.compose.material.ResistanceConfig,androidx.compose.ui.unit.Dp)">swipeable</a></code>.</p>
<p>You should use this state to offset your content accordingly. The recommended way is to use <code>Modifier.offsetPx</code>. This includes the resistance by default, if resistance is enabled.</p>
</div>
<div class="api-item"><a name="getOverflow()"></a><a name="setOverflow()"></a><a name="getOverflow--"></a><a name="setOverflow--"></a>
<h3 class="api-name" id="overflow()">overflow</h3>
<pre class="api-signature no-pretty-print">public&nbsp;final&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/runtime/State.html">State</a>&lt;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/Float.html">Float</a>&gt;&nbsp;<a href="/reference/androidx/compose/material/SwipeableState.html#overflow()">overflow</a></pre>
<p>The amount by which the <code><a href="/reference/androidx/compose/material/package-summary.html#(androidx.compose.ui.Modifier).swipeable(androidx.compose.material.SwipeableState,kotlin.collections.Map,androidx.compose.foundation.gestures.Orientation,kotlin.Boolean,kotlin.Boolean,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Function2,androidx.compose.material.ResistanceConfig,androidx.compose.ui.unit.Dp)">swipeable</a></code> has been swiped past its bounds.</p>
</div>
<div class="api-item"><a name="getProgress()"></a><a name="setProgress()"></a><a name="getProgress--"></a><a name="setProgress--"></a>
<h3 class="api-name" id="progress()">progress</h3>
<pre class="api-signature no-pretty-print">@<a href="/reference/androidx/compose/material/ExperimentalMaterialApi.html">ExperimentalMaterialApi</a><br>public&nbsp;final&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/material/SwipeProgress.html">SwipeProgress</a>&lt;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> T&gt;&nbsp;<a href="/reference/androidx/compose/material/SwipeableState.html#progress()">progress</a></pre>
<p>Information about the ongoing swipe or animation, if any. See <code><a href="/reference/androidx/compose/material/SwipeProgress.html">SwipeProgress</a></code> for details.</p>
<p>If no swipe or animation is in progress, this returns <code>SwipeProgress(value, value, 1f)</code>.</p>
</div>
<div class="api-item"><a name="getTargetValue()"></a><a name="setTargetValue()"></a><a name="getTargetValue--"></a><a name="setTargetValue--"></a>
<h3 class="api-name" id="targetValue()">targetValue</h3>
<pre class="api-signature no-pretty-print">@<a href="/reference/androidx/compose/material/ExperimentalMaterialApi.html">ExperimentalMaterialApi</a><br>public&nbsp;final&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> T&nbsp;<a href="/reference/androidx/compose/material/SwipeableState.html#targetValue()">targetValue</a></pre>
<p>The target value of the state.</p>
<p>If a swipe is in progress, this is the value that the <code><a href="/reference/androidx/compose/material/package-summary.html#(androidx.compose.ui.Modifier).swipeable(androidx.compose.material.SwipeableState,kotlin.collections.Map,androidx.compose.foundation.gestures.Orientation,kotlin.Boolean,kotlin.Boolean,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Function2,androidx.compose.material.ResistanceConfig,androidx.compose.ui.unit.Dp)">swipeable</a></code> would animate to if the swipe finished. If an animation is running, this is the target value of that animation. Finally, if no swipe or animation is in progress, this is the same as the <code><a href="/reference/androidx/compose/material/SwipeableState.html#currentValue()">currentValue</a></code>.</p>
</div>
</div>
<div class="list">
<h2>Public constructors</h2>
<div class="api-item"><a name="SwipeableState(kotlin.Any, androidx.compose.animation.core.AnimationSpec, kotlin.Function1)"></a><a name="SwipeableState-kotlin.Any-androidx.compose.animation.core.AnimationSpec-kotlin.Function1-"></a><a name="swipeablestate"></a>
<h3 class="api-name" id="SwipeableState(kotlin.Any,androidx.compose.animation.core.AnimationSpec,kotlin.Function1)">SwipeableState</h3>
<pre class="api-signature no-pretty-print">public&nbsp;&lt;T&nbsp;extends&nbsp;<a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>&gt; <a href="/reference/androidx/compose/material/SwipeableState.html#SwipeableState(kotlin.Any,androidx.compose.animation.core.AnimationSpec,kotlin.Function1)">SwipeableState</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> T&nbsp;initialValue,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/animation/core/AnimationSpec.html">AnimationSpec</a>&lt;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/Float.html">Float</a>&gt;&nbsp;animationSpec,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> Function1&lt;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> newValue,&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/Boolean.html">Boolean</a>&gt;&nbsp;confirmStateChange<br>)</pre>
<div class="devsite-table-wrapper">
<table class="responsive">
<colgroup>
<col width="40%">
<col>
</colgroup>
<thead>
<tr>
<th colspan="100%">Parameters</th>
</tr>
</thead>
<tbody class="list">
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> T&nbsp;initialValue</code></td>
<td>
<p>The initial value of the state.</p>
</td>
</tr>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/animation/core/AnimationSpec.html">AnimationSpec</a>&lt;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/Float.html">Float</a>&gt;&nbsp;animationSpec</code></td>
<td>
<p>The default animation that will be used to animate to a new state.</p>
</td>
</tr>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> Function1&lt;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> newValue,&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/Boolean.html">Boolean</a>&gt;&nbsp;confirmStateChange</code></td>
<td>
<p>Optional callback invoked to confirm or veto a pending state change.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="list">
<h2>Public methods</h2>
<div class="api-item"><a name="animateTo(kotlin.Any, androidx.compose.animation.core.AnimationSpec)"></a><a name="animateTo-kotlin.Any-androidx.compose.animation.core.AnimationSpec-"></a><a name="animateto"></a>
<h3 class="api-name" id="animateTo(kotlin.Any,androidx.compose.animation.core.AnimationSpec)">animateTo</h3>
<pre class="api-signature no-pretty-print">@<a href="/reference/androidx/compose/material/ExperimentalMaterialApi.html">ExperimentalMaterialApi</a><br>public&nbsp;final&nbsp;void&nbsp;<a href="/reference/androidx/compose/material/SwipeableState.html#animateTo(kotlin.Any,androidx.compose.animation.core.AnimationSpec)">animateTo</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> T&nbsp;targetValue,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/animation/core/AnimationSpec.html">AnimationSpec</a>&lt;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/Float.html">Float</a>&gt;&nbsp;anim<br>)</pre>
<p>Set the state to the target value by starting an animation.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<colgroup>
<col width="40%">
<col>
</colgroup>
<thead>
<tr>
<th colspan="100%">Parameters</th>
</tr>
</thead>
<tbody class="list">
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> T&nbsp;targetValue</code></td>
<td>
<p>The new value to animate to.</p>
</td>
</tr>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/compose/animation/core/AnimationSpec.html">AnimationSpec</a>&lt;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/Float.html">Float</a>&gt;&nbsp;anim</code></td>
<td>
<p>The animation that will be used to animate to the new value.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="api-item"><a name="performDrag-kotlin.Float-"></a><a name="performdrag"></a>
<h3 class="api-name" id="performDrag(kotlin.Float)">performDrag</h3>
<pre class="api-signature no-pretty-print">public&nbsp;final&nbsp;float&nbsp;<a href="/reference/androidx/compose/material/SwipeableState.html#performDrag(kotlin.Float)">performDrag</a>(float&nbsp;delta)</pre>
<p>Force <code><a href="/reference/androidx/compose/material/package-summary.html#(androidx.compose.ui.Modifier).swipeable(androidx.compose.material.SwipeableState,kotlin.collections.Map,androidx.compose.foundation.gestures.Orientation,kotlin.Boolean,kotlin.Boolean,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Function2,androidx.compose.material.ResistanceConfig,androidx.compose.ui.unit.Dp)">swipeable</a></code> to consume drag delta provided from outside of the regular <code><a href="/reference/androidx/compose/material/package-summary.html#(androidx.compose.ui.Modifier).swipeable(androidx.compose.material.SwipeableState,kotlin.collections.Map,androidx.compose.foundation.gestures.Orientation,kotlin.Boolean,kotlin.Boolean,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Function2,androidx.compose.material.ResistanceConfig,androidx.compose.ui.unit.Dp)">swipeable</a></code> gesture flow.</p>
<p>Note: This method performs generic drag and it won't settle to any particular anchor, * leaving swipeable in between anchors. When done dragging, <code><a href="/reference/androidx/compose/material/SwipeableState.html#performFling(kotlin.Float)">performFling</a></code> must be called as well to ensure swipeable will settle at the anchor.</p>
<p>In general cases, <code><a href="/reference/androidx/compose/material/package-summary.html#(androidx.compose.ui.Modifier).swipeable(androidx.compose.material.SwipeableState,kotlin.collections.Map,androidx.compose.foundation.gestures.Orientation,kotlin.Boolean,kotlin.Boolean,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Function2,androidx.compose.material.ResistanceConfig,androidx.compose.ui.unit.Dp)">swipeable</a></code> drags by itself when being swiped. This method is to be used for nested scroll logic that wraps the <code><a href="/reference/androidx/compose/material/package-summary.html#(androidx.compose.ui.Modifier).swipeable(androidx.compose.material.SwipeableState,kotlin.collections.Map,androidx.compose.foundation.gestures.Orientation,kotlin.Boolean,kotlin.Boolean,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Function2,androidx.compose.material.ResistanceConfig,androidx.compose.ui.unit.Dp)">swipeable</a></code>. In nested scroll developer may want to force drag when the child scroll container reaches the bound.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<colgroup>
<col width="40%">
<col>
</colgroup>
<thead>
<tr>
<th colspan="100%">Parameters</th>
</tr>
</thead>
<tbody class="list">
<tr>
<td width="40%"><code>float&nbsp;delta</code></td>
<td>
<p>delta in pixels to drag by</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<colgroup>
<col width="40%">
<col>
</colgroup>
<thead>
<tr>
<th colspan="100%">Returns</th>
</tr>
</thead>
<tbody class="list">
<tr>
<td width="40%"><code>float</code></td>
<td>
<p>the amount of <code><a href="/reference/androidx/compose/material/SwipeableState.html#performDrag(kotlin.Float)">delta</a></code> consumed</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="api-item"><a name="performFling-kotlin.Float-"></a><a name="performfling"></a>
<h3 class="api-name" id="performFling(kotlin.Float)">performFling</h3>
<pre class="api-signature no-pretty-print">public&nbsp;final&nbsp;void&nbsp;<a href="/reference/androidx/compose/material/SwipeableState.html#performFling(kotlin.Float)">performFling</a>(float&nbsp;velocity)</pre>
<p>Perform fling with settling to one of the anchors which is determined by the given <code><a href="/reference/androidx/compose/material/SwipeableState.html#performFling(kotlin.Float)">velocity</a></code>. Fling with settling <code><a href="/reference/androidx/compose/material/package-summary.html#(androidx.compose.ui.Modifier).swipeable(androidx.compose.material.SwipeableState,kotlin.collections.Map,androidx.compose.foundation.gestures.Orientation,kotlin.Boolean,kotlin.Boolean,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Function2,androidx.compose.material.ResistanceConfig,androidx.compose.ui.unit.Dp)">swipeable</a></code> will always consume all the velocity provided since it will settle at the anchor.</p>
<p>In general cases, <code><a href="/reference/androidx/compose/material/package-summary.html#(androidx.compose.ui.Modifier).swipeable(androidx.compose.material.SwipeableState,kotlin.collections.Map,androidx.compose.foundation.gestures.Orientation,kotlin.Boolean,kotlin.Boolean,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Function2,androidx.compose.material.ResistanceConfig,androidx.compose.ui.unit.Dp)">swipeable</a></code> flings by itself when being swiped. This method is to be used for nested scroll logic that wraps the <code><a href="/reference/androidx/compose/material/package-summary.html#(androidx.compose.ui.Modifier).swipeable(androidx.compose.material.SwipeableState,kotlin.collections.Map,androidx.compose.foundation.gestures.Orientation,kotlin.Boolean,kotlin.Boolean,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Function2,androidx.compose.material.ResistanceConfig,androidx.compose.ui.unit.Dp)">swipeable</a></code>. In nested scroll developer may want to trigger settling fling when the child scroll container reaches the bound.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<colgroup>
<col width="40%">
<col>
</colgroup>
<thead>
<tr>
<th colspan="100%">Parameters</th>
</tr>
</thead>
<tbody class="list">
<tr>
<td width="40%"><code>float&nbsp;velocity</code></td>
<td>
<p>velocity to fling and settle with</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<colgroup>
<col width="40%">
<col>
</colgroup>
<thead>
<tr>
<th colspan="100%">Returns</th>
</tr>
</thead>
<tbody class="list">
<tr>
<td width="40%"><code>void</code></td>
<td>
<p>the reason fling ended</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="api-item"><a name="snapTo-kotlin.Any-"></a><a name="snapto"></a>
<h3 class="api-name" id="snapTo(kotlin.Any)">snapTo</h3>
<pre class="api-signature no-pretty-print">@<a href="/reference/androidx/compose/material/ExperimentalMaterialApi.html">ExperimentalMaterialApi</a><br>public&nbsp;final&nbsp;void&nbsp;<a href="/reference/androidx/compose/material/SwipeableState.html#snapTo(kotlin.Any)">snapTo</a>(@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> T&nbsp;targetValue)</pre>
<p>Set the state without any animation and suspend until it's set</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<colgroup>
<col width="40%">
<col>
</colgroup>
<thead>
<tr>
<th colspan="100%">Parameters</th>
</tr>
</thead>
<tbody class="list">
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> T&nbsp;targetValue</code></td>
<td>
<p>The new target value to set <code><a href="/reference/androidx/compose/material/SwipeableState.html#currentValue()">currentValue</a></code> to.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>