Skip to content
New issue

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

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

Already on GitHub? # to your account

Transition fade in AND out creates 2 instances #102

Open
rottmann opened this issue Jan 3, 2022 · 0 comments
Open

Transition fade in AND out creates 2 instances #102

rottmann opened this issue Jan 3, 2022 · 0 comments

Comments

@rottmann
Copy link

rottmann commented Jan 3, 2022

Use your example https://github.com/AlexxNB/tinro#transitions

<!-- Transition.svelte -->
<script>
    import {router} from 'tinro';
    import {fade} from 'svelte/transition';
</script>

{#key $router.path}
    <div in:fade="{{ duration: 700}}">
        <slot></slot>
    </div>
{/key}
<!-- Route.svelte -->
<Transition> 
    <Route path="/">...</Route>
    <Route path="/page1">...</Route>
    <Route path="/page2">...</Route>
</Transition>

When you are at / and navigate to /page1: it fades /page1 in.

But as soon as you add out:fade="{{ duration: 700}}" after in:fade..., you see a fade in transition of /page1 and the full contents of / and /page1 that fade out.

/page1 got instanciated 2 times.

Currently i conceal the view problem with a kind of this code:

<Transition>
  <div style="display: {$router.path === '/' ? 'block' : 'none' }">
    <Route path="/">...</Route>
  </div>

  <div style="display: {$router.path === '/page1' ? 'block' : 'none' }">
    <Route path="/page1">...</Route>
  </div>

  <div style="display: {$router.path === '/page2' ? 'block' : 'none' }">
    <Route path="/page2">...</Route>
  </div>
</Transition>

This does not prevent the router to create 2 instances of /page1

Is there any solution for this?

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

No branches or pull requests

1 participant