Thanks again!
For example I want the confetti effect just when user is over that section.
So if I have this structure:
<div class="clicker" id="clicker"> Clicker </div>
<div class="spacer"> Spacer </div>
<div class="launcher" id="launcher"> Launcher </div>
<div class="spacer">Spacer</div>
I added another ScrollTrigger to stop it once you enter the spacers
let tl = gsap.timeline({
scrollTrigger: {
trigger: ".launcher",
onEnter: myConfetti,
onLeave: confetti.reset(),
toggleActions: "restart pause resume pause"
}
})
let tl2 = gsap.timeline({
scrollTrigger: {
trigger: ".spacer",
onEnter: confetti.reset(),
toggleActions: "restart pause resume pause"
}
})
I don´t think that is doing nothing, the Confetti lasts for 3 seconds anyway:
function myConfetti() {var end = Date.now() + (3 * 1000);
Updated Codepen https://codepen.io/fernandocomet/pen/abjEJvW