Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/binsarjr/svelte-lazyimage-cache

Lazy Image with IntersectionObserver and cache action for Svelte/SvelteKit.
https://github.com/binsarjr/svelte-lazyimage-cache

hacktoberfest lazyimage lazyload svelte svelte-action sveltekit

Last synced: about 1 month ago
JSON representation

Lazy Image with IntersectionObserver and cache action for Svelte/SvelteKit.

Awesome Lists containing this project

README

        

# Svelte Lazy Image Cache
Lazy Image with IntersectionObserver and cache action for Svelte/SvelteKit.

## Contributing
better docs

## Installation
```bash
// Using Yarn to install
yarn add --dev svelte-lazyimage-cache

// or if you prefer NPM
npm install --save-dev svelte-lazyimage-cache
```

## Usage Sample
```svelte

// for first time you will get all image from this load from internet
// its normal because no image cached before
// so if you wanna see its working, try it will with change looping or something reactivity will work
import {lazyimage} from 'svelte-lazyimage-cache'
const placeholder = 'https://media3.giphy.com/media/3oEjI6SIIHBdRxXI40/200.gif'
// try change size and see image load from internet or cache
const src='https://random.imagecdn.app/200/250'
const alt="Random Image"

let onlyForLooping=[]
for(let i=0;i<100;i++){
onlyForLooping[onlyForLooping.length]=''
}

console.log('load from cache')} on:imgload={() => console.log("Load from internet")}/>

{#each onlyForLooping as _}

console.log('load from cache')} on:imgload={() => console.log("Load from internet")}/>
{/each}

```