daylilyfield / svrollbar

simple custom scrollbar made by svelte
https://daylilyfield.github.io/svrollbar/
MIT License
74 stars 12 forks source link

Visibility transition causing rerender issues between routes in Sveltekit #12

Open madeleineostoja opened 2 years ago

madeleineostoja commented 2 years ago

When initiallyVisible or alwaysVisible is true, Svrollbar doesn't properly rerender when changing routes in Sveltekit, causing layout bugs. This only occurs if the one of the visible override props are used, I assume due to the scrollbar not unmounting/updating in time (is there a rogue exit transition or something?)

https://user-images.githubusercontent.com/6374876/168705873-2deca80c-4d58-4f38-9e1e-bd5245a0d066.mov

daylilyfield commented 2 years ago

@madeleineostoja thanks for reporting. could you reproduce this issue in svelte REPL? or do you have any example source code which can reproduce this issue?

madeleineostoja commented 2 years ago

I don't have open source code I can share unfortunately, and putting together a sufficient REPL repro would take a while. Let me see if I can put something together when I have some time

madeleineostoja commented 2 years ago

Just a quick update, haven't had a chance to build an open source repro project, but with further investigation it's not those props, it's whenever there's pending transitions while changing routes. Changing the transition configs (vThumbIn/Out and vTrackIn/Out) to 0 duration fixes the issue, though obviously isn't a great user experience for actual usage.

madeleineostoja commented 2 years ago

My very hacky workaround for now:

<script>
  let scrollReady = true;

  beforeNavigate(() => (scrollReady = false));
  afterNavigate(() => (scrollReady = true));
</script>

{#if scrollReady}
  <Svrollbar ... />
{/if}
iliser commented 2 years ago

Yeah I'm also catch this bug.

This bug caused by svelte transiton design, and mostly appear with relative layout and as described here better solution is just use |local modifier on transition.

Also I open PR #11 for solve this, and right now just use fork -_- while awaiting