Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to activate confetti on out? #9

Open
Bewinxed opened this issue Dec 19, 2022 · 2 comments
Open

How to activate confetti on out? #9

Bewinxed opened this issue Dec 19, 2022 · 2 comments

Comments

@Bewinxed
Copy link

I'm new to svelte, try to make an element explode on exit.

How do I use this in on:out?

@PuruVJ
Copy link
Owner

PuruVJ commented Dec 20, 2022

If I understand your question correctly, you want confetti to go off when an element is destroyed?

If that's the case, you can write code like this:

<script>
let isConfettiVisible = false;

function triggerConfettiOnDestroy(node) {
  return {
    destroy() {
      isConfettiVisible = true;
    }
  }
}
</script>

<div use:triggerConfettiOnDestroy> Destroying me will trigger confetti </div>

{#if isConfettiVisible}
  <div use:confetti />
{/if}

What is on:out listener? Never heard of it 😅

@zakaria-chahboun
Copy link

zakaria-chahboun commented Jan 4, 2023

@PuruVJ I guess he want to destroy the confetti div parent, something like triggering an event when confetti animation is terminated (e.g on:exit event)

<script>
let isConfettiVisible = true;

function exit(){
  isConfettiVisible = false;
}
</script>

{#if isConfettiVisible}
<div class="some classes">
  <Confetti on:exit={exit}/>
</div>
{/if}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants