DanielMartinus / Konfetti

Celebrate more with this lightweight confetti particle system 🎊
ISC License
3.13k stars 299 forks source link

Best approach to programatically start the effects? #305

Open zoltish opened 1 year ago

zoltish commented 1 year ago

Consider a scenario where the user can click a button to start (or restart) the effects, how would I best go about doing that? Current, a bit hackish approach is below. It doesnt seem to have any issues really, but it just seems very ineffective (Im testing on a Pixel 7, lower end devices will likely explode after a while).

    var count by remember {
            mutableStateOf(1)
        }

        repeat(count) {
            KonfettiView(
                modifier = Modifier
                    .fillMaxSize()
                    .clickable(
                        indicate = false,
                        onClick = {
                            count++
                        },
                    ),
                parties= ...
            )
        }