Skip to content

Commit 14f1560

Browse files
committed
Prep for minor release
1 parent a47d118 commit 14f1560

File tree

3 files changed

+465
-363
lines changed

3 files changed

+465
-363
lines changed

README.md

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ The image component renders into:
6060
class="cool cats"
6161
src="path/to/jpg-1920"
6262
srcset="path/to/jpg-480 480w, path/to/jpg-1024 1024w, path/to/jpg-1920 1920w"
63+
width="1920"
64+
height="1080"
6365
loading="lazy"
6466
decoding="async"
6567
style='background: url("data:image/webp;base64,XXX") no-repeat center/cover'
@@ -156,10 +158,10 @@ Use the `svelte-img` component on its own by passing an array of image objects i
156158
import Img from '@zerodevx/svelte-img'
157159
158160
const src = [
159-
{ format: 'avif', src: 'https://x.com/path/to/avif-480', width: 480 },
160-
{ format: 'webp', src: 'https://x.com//path/to/webp-480', width: 480 },
161-
{ format: 'jpg', src: 'https://x.com//path/to/jpg-480', width: 480 },
162-
{ format: 'avif', src: 'https://x.com//path/to/avif-1024', width: 1024 },
161+
{ format: 'avif', src: 'https://x.com/path/to/avif-480', width: 480, height: 120 },
162+
{ format: 'webp', src: 'https://x.com//path/to/webp-480', width: 480, height: 120 },
163+
{ format: 'jpg', src: 'https://x.com//path/to/jpg-480', width: 480, height: 120 },
164+
{ format: 'avif', src: 'https://x.com//path/to/avif-1024', width: 1024, height: 256 },
163165
... // all other variants
164166
{ base64: 'data:image/webp;base64,XXX' } // an optional LQIP with `base64` key
165167
]
@@ -200,9 +202,9 @@ import Img from '@zerodevx/svelte-img'
200202
</style>
201203
```
202204

203-
### New from v1.1
205+
## Special Effects
204206

205-
#### Special effects (Reveal)
207+
#### Fade-in on reveal
206208

207209
Reveal images with a fade-in effect (aka medium.com) when they are loaded _and_ in the viewport.
208210

@@ -213,7 +215,38 @@ import src from '$lib/a/cat.jpg?run'
213215
import { FxReveal as Img } from '@zerodevx/svelte-img'
214216
</script>
215217

216-
<Img {src} alt="cat" />
218+
<Img class="my-img" {src} alt="cat" />
219+
220+
<style>
221+
:global(.my-img) {
222+
width: 640px;
223+
height: 480px;
224+
...
225+
/* These CSS vars are exposed */
226+
--reveal-scale: 1.03;
227+
--reveal-opacity-duration: 1s;
228+
--reveal-transform-duration: 0.6s;
229+
}
230+
</style>
231+
```
232+
233+
#### Parallax
234+
235+
Apply a parallax effect to an image. `factor` is a number between `0` to `1`, where:
236+
237+
- `1` behaves normally (image scrolls along with the page at same speed);
238+
- and `0` essentially fixes the image on the page.
239+
240+
The default factor is `0.75`.
241+
242+
<!-- prettier-ignore -->
243+
```html
244+
<script>
245+
import src from '$lib/a/cat.jpg?run'
246+
import { FxParallax as Img } from '@zerodevx/svelte-img'
247+
</script>
248+
249+
<Img class="w-full h-64" factor="0.5" {src} alt="cat" />
217250
```
218251

219252
## To do

0 commit comments

Comments
 (0)