mirror of
https://github.com/SimpleMobileTools/Simple-Launcher.git
synced 2025-02-17 20:10:36 +01:00
Add a simple bounce on page changes
This commit is contained in:
parent
5f67ff94c0
commit
75aeade4af
@ -20,6 +20,7 @@ import android.util.AttributeSet
|
|||||||
import android.util.Size
|
import android.util.Size
|
||||||
import android.util.SizeF
|
import android.util.SizeF
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.view.animation.OvershootInterpolator
|
||||||
import android.widget.RelativeLayout
|
import android.widget.RelativeLayout
|
||||||
import androidx.core.graphics.drawable.toBitmap
|
import androidx.core.graphics.drawable.toBitmap
|
||||||
import androidx.core.graphics.drawable.toDrawable
|
import androidx.core.graphics.drawable.toDrawable
|
||||||
@ -1032,9 +1033,9 @@ private class AnimatedGridPager(
|
|||||||
|
|
||||||
fun isSwiped() = abs(pageChangeSwipedPercentage) > 0f
|
fun isSwiped() = abs(pageChangeSwipedPercentage) > 0f
|
||||||
|
|
||||||
fun isAnimatingPageChange() = pageChangeAnimLeftPercentage > 0f
|
fun isAnimatingPageChange() = pageChangeAnimLeftPercentage != 0f
|
||||||
|
|
||||||
fun shouldDisplayPageChangeIndicator() = isSwiped() || isAnimatingPageChange() || pageChangeIndicatorsAlpha > 0f
|
fun shouldDisplayPageChangeIndicator() = isSwiped() || isAnimatingPageChange() || pageChangeIndicatorsAlpha != 0f
|
||||||
|
|
||||||
fun getPageChangeIndicatorsAlpha() = if (pageChangeIndicatorsAlpha != 0f) {
|
fun getPageChangeIndicatorsAlpha() = if (pageChangeIndicatorsAlpha != 0f) {
|
||||||
(pageChangeIndicatorsAlpha * 255.0f).toInt()
|
(pageChangeIndicatorsAlpha * 255.0f).toInt()
|
||||||
@ -1078,7 +1079,7 @@ private class AnimatedGridPager(
|
|||||||
currentPage
|
currentPage
|
||||||
}
|
}
|
||||||
val rangeEnd = rangeEndPage.toFloat()
|
val rangeEnd = rangeEndPage.toFloat()
|
||||||
val lerpAmount = if (pageChangeAnimLeftPercentage > 0f) {
|
val lerpAmount = if (pageChangeAnimLeftPercentage != 0f) {
|
||||||
1 - pageChangeAnimLeftPercentage
|
1 - pageChangeAnimLeftPercentage
|
||||||
} else {
|
} else {
|
||||||
abs(pageChangeSwipedPercentage)
|
abs(pageChangeSwipedPercentage)
|
||||||
@ -1248,6 +1249,7 @@ private class AnimatedGridPager(
|
|||||||
}
|
}
|
||||||
ValueAnimator.ofFloat(startingAt, 0f)
|
ValueAnimator.ofFloat(startingAt, 0f)
|
||||||
.apply {
|
.apply {
|
||||||
|
interpolator = OvershootInterpolator(1f)
|
||||||
addUpdateListener {
|
addUpdateListener {
|
||||||
pageChangeAnimLeftPercentage = it.animatedValue as Float
|
pageChangeAnimLeftPercentage = it.animatedValue as Float
|
||||||
redrawGrid()
|
redrawGrid()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user