svelte-imgix
Advanced tools
Comparing version 0.2.3 to 0.2.5
@@ -292,2 +292,5 @@ (function (global, factory) { | ||
} | ||
/** | ||
* Base class for Svelte components. Used when dev=false. | ||
*/ | ||
class SvelteComponent { | ||
@@ -829,3 +832,3 @@ $destroy() { | ||
/* Imgix.svelte generated by Svelte v3.29.7 */ | ||
/* src/Imgix.svelte generated by Svelte v3.31.0 */ | ||
@@ -890,8 +893,13 @@ function create_fragment(ctx) { | ||
let { src } = $$props; | ||
let { alt } = $$props; | ||
let { alt = undefined } = $$props; | ||
let { imgixParams = {} } = $$props; | ||
/** @type {HTMLImageElement} */ | ||
let img; | ||
let intersected = false; | ||
const baseSrc = trimSrc(src); | ||
const placeholder = `${baseSrc}?blur=500&px=8&auto=format`; | ||
/** @type {number[]} */ | ||
const resolutions = []; | ||
@@ -903,7 +911,11 @@ | ||
for (var i = 0; i < resolutions.length; i++) { | ||
const params = Object.assign(Object.assign(Object.assign({}, imgixParams), { w: resolutions[i] }), imgixParams.h | ||
? { | ||
h: Math.round(resolutions[i] * (imgixParams.h / imgixParams.w)) | ||
} | ||
: {}); | ||
const params = { | ||
...imgixParams, | ||
w: resolutions[i], | ||
...imgixParams.h | ||
? { | ||
h: Math.round(resolutions[i] * (imgixParams.h / imgixParams.w)) | ||
} | ||
: {} | ||
}; | ||
@@ -910,0 +922,0 @@ sets.push(`${trimSrc(src)}?${queryString.stringify(params)} ${resolutions[i]}w`); |
{ | ||
"name": "svelte-imgix", | ||
"description": "Responsive, lazily loaded images with Svelte and Imgix", | ||
"version": "0.2.3", | ||
"version": "0.2.5", | ||
"license": "MIT", | ||
"main": "dist/index.js", | ||
"module": "dist/index.mjs", | ||
"svelte": "Imgix.svelte", | ||
"svelte": "./src/index.js", | ||
"types": "./types/index.d.ts", | ||
"scripts": { | ||
"build": "rollup -c", | ||
"develop": "rollup -cw", | ||
"typegen": "sveld", | ||
"prepublishOnly": "npm run build" | ||
@@ -45,3 +47,3 @@ }, | ||
"rollup-plugin-svelte": "^6.1.0", | ||
"svelte-preprocess": "^4.5.2", | ||
"sveld": "^0.5.0", | ||
"tslib": "^2.0.3", | ||
@@ -48,0 +50,0 @@ "typescript": "^4.0.5" |
@@ -26,22 +26,2 @@ # Svelte Imgix | ||
#### Svelte-preprocess | ||
`svelte-meta` is written in Typescript, and requires Svelte's preprocessing to be enabled. If you're using [Sapper](https://sapper.svelte.dev/) this comes enabled by default. | ||
To enable preprocessing, install `svelte-preprocess` and include it in the svelte config in your `rollup.config.js` or `webpack.config.js` | ||
```sh | ||
npm i svelte-preprocess | ||
``` | ||
```js | ||
import autoPreprocess from 'svelte-preprocess'; | ||
svelte({ | ||
preprocess: autoPreprocess() | ||
}); | ||
``` | ||
See the [svelte-preprocess docs](https://github.com/sveltejs/svelte-preprocess) for more. | ||
### Adding Sizes | ||
@@ -69,6 +49,6 @@ | ||
| Property | Description | | ||
| ------------- | ------------------------------------------------------------------------------------- | | ||
| `src` | Imgix source of the image | | ||
| `alt` | Alt text for the image | | ||
| `ImgixParams` | Object of Imgix parameters to set on the image, overrides any defaults given in `src` | | ||
| Property | Type | Description | | ||
| ------------- | -------- | ------------------------------------------------------------------------------------- | | ||
| `src` | `string` | Imgix source of the image | | ||
| `alt` | `string` | Alt text for the image | | ||
| `ImgixParams` | `object` | Object of Imgix parameters to set on the image, overrides any defaults given in `src` | |
Sorry, the diff of this file is not supported yet
1704
56888
4
53