Skip to content

Instantly share code, notes, and snippets.

@kibotu
Created October 21, 2021 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kibotu/d4e72e330c260f161a683f12e452462b to your computer and use it in GitHub Desktop.
Save kibotu/d4e72e330c260f161a683f12e452462b to your computer and use it in GitHub Desktop.
Wooble All
// 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