Skip to content

Commit dfce98a

Browse files
committed
Minor formatting updates
1 parent 6aa7e69 commit dfce98a

File tree

1 file changed

+29
-28
lines changed

1 file changed

+29
-28
lines changed

README.md

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ The image component renders into:
107107

108108
## Features
109109

110-
#### Change default widths/formats
110+
### Change default widths/formats
111111

112112
By default, `svelte-img` generates 9 variants of an original full-sized image - at `480/1024/1920`
113113
widths in `avif/webp/jpg` formats; and a `16px webp/base64` low-quality image placeholder (LQIP).
@@ -132,12 +132,11 @@ export default defineConfig({
132132
```
133133

134134
> [!IMPORTANT]
135-
> This package works alongside standard `vite-imagetools`; the `?as=run` preset takes default
136-
> directives from `runDefaultDirectives`! Without using the preset, behaviour falls back to standard
137-
> imagetools, which takes default directives from `defaultDirectives` as usual, so both can
138-
> co-exist.
135+
> The `?as=run` preset takes default directives from **`runDefaultDirectives`**! When the preset is
136+
> not used, behaviour falls back to standard `vite-imagetools`, which in turn take defaults from
137+
> `defaultDirectives` as usual, so both can co-exist.
139138
140-
#### On a per-image basis
139+
### On a per-image basis
141140

142141
Widths/formats can be applied to a particular image. From your `.svelte` file:
143142

@@ -153,16 +152,18 @@ Widths/formats can be applied to a particular image. From your `.svelte` file:
153152
```
154153

155154
> [!IMPORTANT]
156-
> Order of `format` is important - the _last_ format is used as the fallback image of the HTML
157-
> `<img>` tag.
155+
> Order of `format` is important - the _last_ format is used as the fallback image.
158156
159-
If only **one** variant is generated, the `<picture>` tag will not be rendered since it's redundant.
157+
If only **one** variant is generated, the `<picture>` tag **won't** be rendered since it's
158+
redundant.
159+
160+
So:
160161

161162
<!-- prettier-ignore -->
162163
```html
163164
<script>
164165
// Generate only 1 variant: 640x640 in png
165-
import src from '$lib/a/cat.jpg?w=640&h=640&format=png&as=run:0'
166+
import src from '$lib/a/cat.jpg?w=640&h=640&format=png&as=run'
166167
import Img from '@zerodevx/svelte-img'
167168
</script>
168169

@@ -183,15 +184,15 @@ Renders into:
183184
/>
184185
```
185186

186-
#### Change LQIP width
187+
### Change LQIP width
187188

188189
LQIP is controlled by the `run` directive param. Using `?as=run` defaults to `16px` LQIP -
189-
equivalent to `?as=run:16`. Increase for a higher quality LQIP (eg `?as=run:32` for `32px` LQIP) at
190-
the expense of a larger inline `base64` (larger HTML size).
190+
functionally equivalent to `?as=run:16`. Increase for a higher quality LQIP (eg. `?as=run:32` for
191+
`32px` LQIP) at the expense of a larger inline `base64` (larger HTML size).
191192

192193
To disable LQIP, set `?as=run:0`.
193194

194-
For a dominant single-colour background, set `?as=run:1`.
195+
For a dominant single-colour background, set `?as=run:1`, like so:
195196

196197
<!-- prettier-ignore -->
197198
```html
@@ -214,7 +215,7 @@ Renders into:
214215
</picture>
215216
```
216217

217-
#### Other transformations
218+
### Other transformations
218219

219220
The full [repertoire](https://github.com/JonasKruckenberg/imagetools/blob/main/docs/directives.md)
220221
of transformation directives offered by
@@ -223,18 +224,18 @@ of transformation directives offered by
223224
<!-- prettier-ignore -->
224225
```html
225226
<script>
226-
// Generate all 9 variants at fixed height
227+
// Generate all 9 variants at fixed 600px height
227228
import src from '$lib/a/cat.jpg?h=600&fit=cover&normalize&as=run'
228229
import Img from '@zerodevx/svelte-img'
229230
</script>
230231

231232
<Img {src} alt="cat" />
232233
```
233234

234-
#### Art direction
235+
### Art direction
235236

236237
Use the `sizes` attribute to define a set of media conditions to hint which image size to select
237-
when these conditions are true. Read up more on the
238+
when those conditions are true. Read up more on the
238239
[art direction problem](https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images).
239240

240241
<!-- prettier-ignore -->
@@ -244,11 +245,11 @@ when these conditions are true. Read up more on the
244245
import Img from '@zerodevx/svelte-img'
245246
</script>
246247
247-
<!-- If viewport is <=600px, use 480px as breakpoint -->
248+
<!-- If viewport is <=600px, use 480px as viewport width -->
248249
<Img {src} alt="cat" sizes="(max-width: 600px) 480px, 800px" />
249250
```
250251
251-
#### Lazy loading
252+
### Lazy loading
252253
253254
`svelte-img` utilises the browser's native lazy loading capability by setting the `loading="lazy"`
254255
attribute on the rendered `<img>` tag by default. This is supported by
@@ -264,7 +265,7 @@ attribute on the rendered `<img>` tag by default. This is supported by
264265
<Img {src} alt="cat" loading="eager" />
265266
```
266267
267-
#### Batch loading local images
268+
### Batch loading local images
268269
269270
Use Vite's `import.meta.glob` [feature](https://vitejs.dev/guide/features.html#glob-import).
270271
@@ -286,7 +287,7 @@ Use Vite's `import.meta.glob` [feature](https://vitejs.dev/guide/features.html#g
286287
{/each}
287288
```
288289
289-
#### Remote images from an API
290+
### Remote images from an API
290291
291292
Use the `svelte-img` component on its own by passing a `src` object, like so:
292293
@@ -314,7 +315,7 @@ const src = {
314315
<Img {src} alt="cat" />
315316
```
316317
317-
#### Blurred image placeholders
318+
### Blurred image placeholders
318319
319320
Natively, browsers do already apply _some_ blur when displaying low resolution images. That's enough
320321
for me, but you can apply your own using CSS.
@@ -346,7 +347,7 @@ for me, but you can apply your own using CSS.
346347
347348
## Special Effects
348349
349-
#### Fade-in on reveal
350+
### Fade-in on reveal
350351
351352
Reveal images with a fade-in/zoom effect (aka medium.com) when they are loaded **and** in the
352353
viewport.
@@ -373,14 +374,14 @@ viewport.
373374
</style>
374375
```
375376
376-
#### Parallax
377+
### Parallax
377378
378-
Apply a parallax effect to an image, where `factor` is a decimal value between 0 and 1 that controls
379-
how much slower the element scrolls relative to the scrolling speed:
379+
Apply a vertical parallax scrolling effect to an image, where `factor` is a decimal value between 0
380+
and 1, that controls how much slower the element scrolls, relative to the scrolling speed:
380381
381382
- A value closer to 0 is faster, while a value closer to 1 is slower.
382383
- A value of 1 behaves normally.
383-
- A value of 0 effectively makes the element scroll fixed with the page.
384+
- A value of 0 effectively makes the element fixed on the page.
384385
385386
The default factor is `0.75`.
386387

0 commit comments

Comments
 (0)