svelte-imgix
Advanced tools
Comparing version
@@ -610,13 +610,10 @@ (function (global, factory) { | ||
function lazyImg(img, src) { | ||
let intersected = false; | ||
const observer = new IntersectionObserver((entries, observer) => { | ||
intersected = entries[0].isIntersecting; | ||
if (entries[0].intersectionRatio > 0) { | ||
if (entries[0].isIntersecting) { | ||
img.src = src; | ||
img.srcset = srcset(src); | ||
} | ||
if (intersected) { | ||
observer.unobserve(img); | ||
} | ||
}); | ||
img.srcset = ''; | ||
img.src = placeholder(src); | ||
@@ -623,0 +620,0 @@ observer.observe(img); |
{ | ||
"name": "svelte-imgix", | ||
"description": "Svelte action for responsive, lazily-loaded images with Imgix", | ||
"version": "2.4.0", | ||
"version": "2.4.1", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "author": "Madeleine Ostoja", |
@@ -43,3 +43,3 @@ # Svelt Imgix | ||
Until Svelte supports actions running in SSR, you might notice images don't have a src at all until `svelte-imgix` has hydrated. As a workaround, use the `placeholder` helper function to SSR an LQIP placeholder image manually. Svelte-imgix will then hydrate from there, with the same placeholder image, and load your full srcset once the image enters the viewport. | ||
Until Svelte [supports actions running in SSR](https://github.com/sveltejs/svelte/issues/4375), you might notice images don't have a src at all until `svelte-imgix` has hydrated. As a workaround, use the `placeholder` helper function to SSR an LQIP placeholder image manually. Svelte-imgix will then hydrate from there, with the same placeholder image, and load your full srcset once the image enters the viewport. | ||
@@ -46,0 +46,0 @@ ```svelte |
Sorry, the diff of this file is not supported yet
35351
-0.44%1022
-0.58%