svelte-imgix
Advanced tools
Comparing version 2.2.5 to 2.3.0
@@ -1,4 +0,5 @@ | ||
export declare function generateSrcset(src: string): string; | ||
export declare function srcset(src: string): string; | ||
export declare function placeholder(src: string): string; | ||
export default function imgix(img: HTMLImageElement, src: string): { | ||
destroy(): void; | ||
}; |
@@ -591,3 +591,3 @@ (function (global, factory) { | ||
} | ||
function generateSrcset(src) { | ||
function srcset(src) { | ||
const resolutions = [], sets = []; | ||
@@ -607,2 +607,5 @@ let prev = 100; | ||
} | ||
function placeholder(src) { | ||
return `${trimSrc(src)}?w=0.5&blur=200&px=16&auto=format&colorquant=150`; | ||
} | ||
function imgix(img, src) { | ||
@@ -614,3 +617,3 @@ let intersected = false; | ||
img.src = src; | ||
img.srcset = generateSrcset(src); | ||
img.srcset = srcset(src); | ||
} | ||
@@ -621,3 +624,3 @@ if (intersected) { | ||
}); | ||
img.src = `${trimSrc(src)}?w=0.5&blur=200&px=16&auto=format&colorquant=150`; | ||
img.src = placeholder(src); | ||
observer.observe(img); | ||
@@ -632,3 +635,4 @@ return { | ||
exports.default = imgix; | ||
exports.generateSrcset = generateSrcset; | ||
exports.placeholder = placeholder; | ||
exports.srcset = srcset; | ||
@@ -635,0 +639,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
{ | ||
"name": "svelte-imgix", | ||
"description": "Svelte action for responsive, lazily-loaded images with Imgix", | ||
"version": "2.2.5", | ||
"version": "2.3.0", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "author": "Madeleine Ostoja", |
@@ -26,2 +26,17 @@ # Svelt Imgix | ||
### Helper functions | ||
Svelte Imgix exports 2 additional helper functions that you can use to create LQIP placeholders and responsive srcsets yourself, `placeholder(src)` and `srcset(src`; | ||
```svelte | ||
<script> | ||
import { placeholder, srcset } from 'svelte-imgix'; | ||
import { invew } from 'svelte-inview'; | ||
let intersected = false; | ||
</script> | ||
<img src={intersected ? srcset(imgixImg) : placeholder(imgixImg)} use:invew on:enter={() => intersected = true} /> | ||
``` | ||
### Adding Sizes | ||
@@ -28,0 +43,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34603
1011
46