Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge "Adds correct AnimationSpec for scrolling between tabs" into an…
…droidx-master-dev
  • Loading branch information
Treehugger Robot authored and Gerrit Code Review committed Nov 26, 2020
2 parents 3126b56 + 094cb9f commit 877ff98
Showing 1 changed file with 12 additions and 1 deletion.
Expand Up @@ -16,6 +16,9 @@

package androidx.compose.material

import androidx.compose.animation.core.AnimationSpec
import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.tween
import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.fillMaxWidth
Expand Down Expand Up @@ -305,7 +308,7 @@ private class ScrollableTabData(
// Scrolls to the tab with [tabPosition], trying to place it in the center of the
// screen or as close to the center as possible.
val calculatedOffset = it.calculateTabOffset(density, edgeOffset, tabPositions)
scrollState.smoothScrollTo(calculatedOffset)
scrollState.smoothScrollTo(calculatedOffset, spec = ScrollableTabRowScrollSpec)
}
}
}
Expand Down Expand Up @@ -334,3 +337,11 @@ private class ScrollableTabData(
}

private val ScrollableTabRowMinimumTabWidth = 90.dp

/**
* [AnimationSpec] used when scrolling to a tab that is not fully visible.
*/
private val ScrollableTabRowScrollSpec: AnimationSpec<Float> = tween(
durationMillis = 250,
easing = FastOutSlowInEasing
)

0 comments on commit 877ff98

Please sign in to comment.