Created
May 14, 2020 11:17
-
-
Save AshuTyagi16/f6bf1441ff97f7f8aac697f89a8a151f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var currentVelocity = 0f | |
/** | |
* A [SpringAnimation] for this RecyclerView item. This animation rotates the view with a bouncy | |
* spring configuration, resulting in the oscillation effect. | |
* | |
* The animation is started in [Recyclerview.onScrollListener]. | |
*/ | |
val rotation: SpringAnimation = SpringAnimation(itemView, SpringAnimation.ROTATION) | |
.setSpring( | |
SpringForce() | |
.setFinalPosition(0f) | |
.setDampingRatio(SpringForce.DAMPING_RATIO_HIGH_BOUNCY) | |
.setStiffness(SpringForce.STIFFNESS_LOW) | |
) | |
.addUpdateListener { _, _, velocity -> | |
currentVelocity = velocity | |
} | |
/** | |
* A [SpringAnimation] for this RecyclerView item. This animation is used to bring the item back | |
* after the over-scroll effect. | |
*/ | |
val translationY: SpringAnimation = SpringAnimation(itemView, SpringAnimation.TRANSLATION_Y) | |
.setSpring( | |
SpringForce() | |
.setFinalPosition(0f) | |
.setDampingRatio(SpringForce.DAMPING_RATIO_MEDIUM_BOUNCY) | |
.setStiffness(SpringForce.STIFFNESS_LOW) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment