@motion-proto/live-tokens 0.35.0 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.37.0 — ImageLightbox `capNatural` accepts a multiple
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **`ImageLightbox`'s `capNatural` now takes a number as well as a boolean.**
|
|
8
|
+
`true` still caps the open fit at 1:1 (100%); a number caps at that multiple of
|
|
9
|
+
the source's natural resolution (`capNatural={2}` = up to 200%). This allows a
|
|
10
|
+
small source to open a little larger than native without being upscaled all the
|
|
11
|
+
way to the viewport. Backward compatible — the boolean form is unchanged.
|
|
12
|
+
|
|
13
|
+
## 0.36.0 — ImageLightbox `capNatural`: stop upscaling small sources
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- **`ImageLightbox` gains a `capNatural` prop.** By default the modal opens
|
|
18
|
+
fitted to the viewport, which upscales a small source (e.g. a low-res GIF or
|
|
19
|
+
screenshot) until it looks soft. Set `capNatural` and the open fit is clamped
|
|
20
|
+
to the source's natural resolution (100%, 1 source px = 1 screen px), so small
|
|
21
|
+
images stay crisp while larger ones fit the viewport exactly as before. It only
|
|
22
|
+
bounds the initial open; pair it with `maxZoom={1}` to also stop the `extended`
|
|
23
|
+
zoom controls from magnifying past 100%. Needs the natural pixel size (from
|
|
24
|
+
`width`/`height` or the loaded image) — until that's known the image fits the
|
|
25
|
+
viewport, then snaps to the cap once measured.
|
|
26
|
+
|
|
3
27
|
## 0.35.0 — Dev routes moved to a reserved `/live-tokens/*` namespace
|
|
4
28
|
|
|
5
29
|
### Changed (breaking)
|
package/package.json
CHANGED
|
@@ -28,12 +28,23 @@
|
|
|
28
28
|
extended?: boolean;
|
|
29
29
|
/** Maximum zoom, as a multiple of the image's natural resolution: `1` = 100%
|
|
30
30
|
of the source's real pixels (1 source px = 1 screen px), `2` = 200%. The
|
|
31
|
-
modal
|
|
32
|
-
|
|
33
|
-
An image whose fitted size already
|
|
34
|
-
in. Needs the natural pixel size
|
|
35
|
-
image); until that's known the
|
|
31
|
+
modal opens fitted to the viewport (or to a `capNatural`-capped size when
|
|
32
|
+
that's set); this only caps how far the `extended` zoom controls magnify.
|
|
33
|
+
Unset = the default 5x-the-fit cap. An image whose fitted size already
|
|
34
|
+
exceeds the cap simply can't be zoomed in. Needs the natural pixel size
|
|
35
|
+
(from `width`/`height`, or the loaded image); until that's known the
|
|
36
|
+
default cap applies. */
|
|
36
37
|
maxZoom?: number | undefined;
|
|
38
|
+
/** Cap the opened image's fit relative to its natural resolution, so a small
|
|
39
|
+
source (e.g. a low-res GIF) isn't upscaled to fill the viewport until it
|
|
40
|
+
looks soft. `true` caps at 1:1 (100%); a number caps at that multiple
|
|
41
|
+
(`2` = up to 200% of native). The modal still opens centered and never
|
|
42
|
+
below the viewport fit, so larger sources are unaffected. Only bounds the
|
|
43
|
+
initial open fit — the `extended` zoom controls still run up to `maxZoom`
|
|
44
|
+
(pair with `maxZoom` to also bound zoom). Needs the natural pixel size
|
|
45
|
+
(from `width`/`height`, or the loaded image); until that's known the image
|
|
46
|
+
fits the viewport, then snaps to the cap once measured. */
|
|
47
|
+
capNatural?: boolean | number;
|
|
37
48
|
}
|
|
38
49
|
|
|
39
50
|
let {
|
|
@@ -46,6 +57,7 @@
|
|
|
46
57
|
fit = 'contain',
|
|
47
58
|
extended = false,
|
|
48
59
|
maxZoom = undefined,
|
|
60
|
+
capNatural = false,
|
|
49
61
|
}: Props = $props();
|
|
50
62
|
|
|
51
63
|
const items = $derived(
|
|
@@ -151,7 +163,12 @@
|
|
|
151
163
|
if (!aspect) {
|
|
152
164
|
return { top: vh * 0.04, left: vw * 0.03, width: capW, height: capH };
|
|
153
165
|
}
|
|
154
|
-
|
|
166
|
+
let tileW = Math.min(capW, capH * aspect);
|
|
167
|
+
if (capNatural) {
|
|
168
|
+
const nw = naturalWidthOf(current);
|
|
169
|
+
const mult = capNatural === true ? 1 : capNatural;
|
|
170
|
+
if (nw) tileW = Math.min(tileW, nw * mult);
|
|
171
|
+
}
|
|
155
172
|
const tileH = tileW / aspect;
|
|
156
173
|
return {
|
|
157
174
|
top: (vh - tileH) / 2,
|