leafOfTree / svelte-lazy

A svelte component to lazyload any content including images

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Svelte Routify - Components don't load on page change.

doolijb opened this issue · comments

Using Routify, components don't load on new pages until scroll has been triggered.

Routify2 - Current workaround on each page:

import { afterPageLoad } from '@roxi/routify'
$afterPageLoad(() => document.dispatchEvent(new CustomEvent('scroll')))
commented

Hi, @doolijb. Thanks for your feedback.

I did some investigation and found out that when changing pages, Routify probably removes the previous page dom and renders the new page dom simultaneously. It results in incorrect height from node.getBoundingClientRect().top for svelte-lazy not to load the component.

I simply added a timeout for initial loading checking. Please try the latest version npm install svelte-lazy and see if it works.

Thanks for the quick response, I'll check tomorrow

It's looking good in production with Firefox and Chrome, thanks a ton.