mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-23 08:30:44 +00:00
Enhanced `View.slideUp
`
This commit is contained in:
parent
9e44053e22
commit
8b807b0706
@ -299,18 +299,36 @@ private fun View.animateLightSlideAndAlpha(enterOrExit: Boolean, duration: Long,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun View.slideUp(duration: Long, delay: Long, @FloatRange(from = 0.0, to = 1.0) translationPercent: Float) {
|
fun View.slideUp(
|
||||||
|
duration: Long,
|
||||||
|
delay: Long,
|
||||||
|
@FloatRange(from = 0.0, to = 1.0) translationPercent: Float
|
||||||
|
) {
|
||||||
|
slideUp(duration, delay, translationPercent)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun View.slideUp(
|
||||||
|
duration: Long,
|
||||||
|
delay: Long = 0L,
|
||||||
|
@FloatRange(from = 0.0, to = 1.0) translationPercent: Float = 1.0F,
|
||||||
|
execOnEnd: Runnable? = null
|
||||||
|
) {
|
||||||
val newTranslationY = (resources.displayMetrics.heightPixels * translationPercent).toInt()
|
val newTranslationY = (resources.displayMetrics.heightPixels * translationPercent).toInt()
|
||||||
animate().setListener(null).cancel()
|
animate().setListener(null).cancel()
|
||||||
alpha = 0f
|
alpha = 0f
|
||||||
translationY = newTranslationY.toFloat()
|
translationY = newTranslationY.toFloat()
|
||||||
visibility = View.VISIBLE
|
isVisible = true
|
||||||
animate()
|
animate()
|
||||||
.alpha(1f)
|
.alpha(1f)
|
||||||
.translationY(0f)
|
.translationY(0f)
|
||||||
.setStartDelay(delay)
|
.setStartDelay(delay)
|
||||||
.setDuration(duration)
|
.setDuration(duration)
|
||||||
.setInterpolator(FastOutSlowInInterpolator())
|
.setInterpolator(FastOutSlowInInterpolator())
|
||||||
|
.setListener(object : AnimatorListenerAdapter() {
|
||||||
|
override fun onAnimationEnd(animation: Animator) {
|
||||||
|
execOnEnd?.run()
|
||||||
|
}
|
||||||
|
})
|
||||||
.start()
|
.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user