Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dimfeld/svelte-lazyload

Use an IntersectionObserver to delay loading elements until they are about to enter the viewport.
https://github.com/dimfeld/svelte-lazyload

lazy lazy-loading svelte

Last synced: 12 days ago
JSON representation

Use an IntersectionObserver to delay loading elements until they are about to enter the viewport.

Awesome Lists containing this project

README

        

# svelte-lazyload

This is a small component that uses an `IntersectionObserver` to delay loading some element of a page until it is about to enter the viewport. It exposes a property `visible` indicating if the element has been created, and also fires an event named `visible` when it loads the element.

```svelte

import { fade } from 'svelte/transition';
import LazyLoad from '@dimfeld/svelte-lazyload';
let visible = false;


Visible: {visible}

console.log('visible!')}>

Hello!

```

Try it in the [Svelte REPL](https://svelte.dev/repl/9a2f40ce30b34337be76df5e9be168e8)!.