Explode compose elements on click! Just add explodeOnClick() modifier!
Inspired from ExplosionField
- Go to library/explodeOnClick.kt
- Copy paste the
explodeOnClick.ktfile in your compose project. - That's it
p.s. I'm too lazy to release this on maven. Please bear with me I'll do it soon.
Just add explodeOnClick() modifier on your composable element.
Text(
text = "Click me to explode!",
// Just add this modifier
modifier = Modifier.explodeOnClick()
)Lambda will be called when user clicks the element. You can pass onClick if you want to perform any action on click.
Modifier.explodeOnClick(color = backColor,
onClick = {
Toast
.makeText(context, "Toast message", Toast.LENGTH_LONG)
.show()
})Set the duration of animation, default is 1 sec.
modifier = Modifier.explodeOnClick(durationMillis=1500)Set easing for the animation, default is LinearEasing.
modifier = Modifier.explodeOnClick(easing=LinearEasing)Set the color of the animation/particles, default is Color.Black.
modifier = Modifier.explodeOnClick(color = Color.GREEN)Set if you want to make the animation repeatable again after click.
modifier = Modifier.explodeOnClick(repeatable = true)Which looks like this ..
Please contribute if you feel there's something missing or anything you feel right. Just raise a PR, I would be happy to accept.
Licensed under Apache License, Version 2.0 here

