Created
October 21, 2021 08:32
-
-
Save kibotu/d4e72e330c260f161a683f12e452462b to your computer and use it in GitHub Desktop.
Wooble All
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
// implementation "com.github.kibotu:AndroidAnimationsActions:2.0.1" | |
// maven { url 'https://jitpack.io' } | |
fun ViewGroup.woobleEVERYTHING() = children.forEach { it.startWobbling() } | |
fun View.startWobbling() { | |
val minDuration = 1f | |
val maxDuration = 1.5f | |
val duration: Float = randomRange(minDuration, maxDuration) | |
play( | |
forever( | |
sequence( | |
scaleTo(0.5f, 1f, duration, Interpolations.SineEaseInOut), | |
scaleTo(1f, 0.5f, duration, Interpolations.SineEaseInOut), | |
) | |
), | |
this | |
) | |
} | |
private fun randomRange(start: Float, end: Float): Float = Random().nextFloat() * (end - start) + start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment