Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

NotificationsYou must be signed in to change notification settings

binsarjr/svelte-lazyimage-cache

Repository files navigation

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

Contributing

better docs

Installation

// Using Yarn to installyarn add --dev svelte-lazyimage-cache// orif you prefer NPMnpm install --save-dev svelte-lazyimage-cache

Usage Sample

<script>// 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 workimport {lazyimage}from'svelte-lazyimage-cache'constplaceholder='https://media3.giphy.com/media/3oEjI6SIIHBdRxXI40/200.gif'// try change size and see image load from internet or cacheconstsrc='https://random.imagecdn.app/200/250'constalt="Random Image"let onlyForLooping=[]for(let i=0;i<100;i++){onlyForLooping[onlyForLooping.length]=''}</script><!-- No Cache --><imguse:lazyimage={{cache:false}}src={placeholder}data-src="{src}" {alt}on:cacheload={()=>console.log('load from cache')}on:imgload={()=>console.log("Load from internet")}/><!--Check console when scrolling. if your brwoser support intersection observerand you enable cache,another image with same url (cached) will use instead of load from internet-->{#eachonlyForLoopingas_}<!-- With Cache  --><imguse:lazyimagesrc={placeholder}data-src={src} {alt}on:cacheload={()=>console.log('load from cache')}on:imgload={()=>console.log("Load from internet")}/>{/each}

About

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

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp