@zakisheriff/liquid-glass 0.3.13 → 0.3.15
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/dist/index.d.mts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +28 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -272,7 +272,12 @@ interface GlassShape {
|
|
|
272
272
|
*/
|
|
273
273
|
copy?: boolean | 'refract';
|
|
274
274
|
}
|
|
275
|
-
/**
|
|
275
|
+
/**
|
|
276
|
+
* Only Chromium runs SVG filters inside `backdrop-filter`, and only desktop
|
|
277
|
+
* GPUs carry it: it re-runs over the live backdrop every frame, which holds
|
|
278
|
+
* even flagship Android phones near 30fps. Android takes the path iPhones do
|
|
279
|
+
* (lenses refract a live copy, resting glass keeps blur and rim).
|
|
280
|
+
*/
|
|
276
281
|
declare function canRefractBackdrop(): boolean;
|
|
277
282
|
/**
|
|
278
283
|
* Bakes refraction for `ref`'s current box (untransformed) and keeps it fresh
|
package/dist/index.d.ts
CHANGED
|
@@ -272,7 +272,12 @@ interface GlassShape {
|
|
|
272
272
|
*/
|
|
273
273
|
copy?: boolean | 'refract';
|
|
274
274
|
}
|
|
275
|
-
/**
|
|
275
|
+
/**
|
|
276
|
+
* Only Chromium runs SVG filters inside `backdrop-filter`, and only desktop
|
|
277
|
+
* GPUs carry it: it re-runs over the live backdrop every frame, which holds
|
|
278
|
+
* even flagship Android phones near 30fps. Android takes the path iPhones do
|
|
279
|
+
* (lenses refract a live copy, resting glass keeps blur and rim).
|
|
280
|
+
*/
|
|
276
281
|
declare function canRefractBackdrop(): boolean;
|
|
277
282
|
/**
|
|
278
283
|
* Bakes refraction for `ref`'s current box (untransformed) and keeps it fresh
|
package/dist/index.js
CHANGED
|
@@ -183,8 +183,8 @@ var SPRINGS = {
|
|
|
183
183
|
/** A dragged lens's stretch: loose, so it wobbles when the drag stops. */
|
|
184
184
|
jelly: springFrom(0.3, 0.3)
|
|
185
185
|
};
|
|
186
|
-
function createJelly(onUpdate, max, speed) {
|
|
187
|
-
const spring = createSpring(0,
|
|
186
|
+
function createJelly(onUpdate, max, speed, config = SPRINGS.jelly) {
|
|
187
|
+
const spring = createSpring(0, config, (value) => onUpdate(value));
|
|
188
188
|
return {
|
|
189
189
|
feed(velocity) {
|
|
190
190
|
spring.set(max * Math.tanh(Math.abs(velocity) / speed));
|
|
@@ -680,7 +680,7 @@ function container() {
|
|
|
680
680
|
function canRefractBackdrop() {
|
|
681
681
|
if (typeof navigator === "undefined") return false;
|
|
682
682
|
const ua = navigator.userAgent;
|
|
683
|
-
return /Chrom(e|ium)\/|Edg\//.test(ua) && !/CriOS|FxiOS|EdgiOS/.test(ua);
|
|
683
|
+
return /Chrom(e|ium)\/|Edg\//.test(ua) && !/CriOS|FxiOS|EdgiOS|Android/.test(ua);
|
|
684
684
|
}
|
|
685
685
|
function bevelProfile(bezel, thickness, ior) {
|
|
686
686
|
const N = 256;
|
|
@@ -1756,6 +1756,11 @@ var import_react9 = require("react");
|
|
|
1756
1756
|
// src/engine/lensTrack.ts
|
|
1757
1757
|
var import_react8 = require("react");
|
|
1758
1758
|
var FOLLOW2 = springFrom(0.2, 0.82);
|
|
1759
|
+
var PULL_REACH = 0.08;
|
|
1760
|
+
var PULL_GIVE = 0.15;
|
|
1761
|
+
var DRAG = springFrom(0.14, 0.84);
|
|
1762
|
+
var WOBBLE = springFrom(0.34, 0.2);
|
|
1763
|
+
var LAND = springFrom(0.38, 0.6);
|
|
1759
1764
|
function useLensTrack(refs, options) {
|
|
1760
1765
|
const latest = (0, import_react8.useRef)(options);
|
|
1761
1766
|
latest.current = options;
|
|
@@ -1828,15 +1833,18 @@ function useLensTrack(refs, options) {
|
|
|
1828
1833
|
if (!W || !H) return;
|
|
1829
1834
|
const kx = (slot + (W - slot) * lift2) / W * (1 + squash);
|
|
1830
1835
|
const ky = (height + (H - height) * lift2) / H * (1 - squash * 0.6);
|
|
1831
|
-
const grow = 1 + latest.current.swell / Math.max(bar.offsetWidth, 1) * swell2;
|
|
1832
1836
|
const pull2 = state.pull;
|
|
1833
|
-
const
|
|
1837
|
+
const h = Math.max(bar.offsetHeight, 1);
|
|
1838
|
+
const reach = Math.abs(pull2);
|
|
1839
|
+
const taken = clamp(reach / (h * PULL_REACH), 0, 1);
|
|
1840
|
+
const grow = 1 + latest.current.swell / Math.max(bar.offsetWidth, 1) * swell2 * (1 - taken * 0.85);
|
|
1841
|
+
const lean = Math.sign(pull2) * (reach / 2 + h * 0.03 * taken);
|
|
1834
1842
|
const transform = `translateX(${x2}px) scale(${kx}, ${ky})`;
|
|
1835
1843
|
lens.style.transform = transform;
|
|
1836
1844
|
select.style.transform = `translateX(${x2}px)`;
|
|
1837
1845
|
lens.style.opacity = String(clamp(lift2 * 4, 0, 1));
|
|
1838
|
-
shell.style.scale = `${grow * (1 -
|
|
1839
|
-
shell.style.translate = `0px ${
|
|
1846
|
+
shell.style.scale = `${grow * (1 - taken * 0.04)} ${grow + reach / h}`;
|
|
1847
|
+
shell.style.translate = `0px ${lean}px`;
|
|
1840
1848
|
lens.style.setProperty("--lg-lift", String(clamp(lift2, 0, 1)));
|
|
1841
1849
|
bar.style.setProperty("--lg-lift", String(clamp(lift2, 0, 1)));
|
|
1842
1850
|
for (const glyph of glyphs) {
|
|
@@ -1892,8 +1900,8 @@ function useLensTrack(refs, options) {
|
|
|
1892
1900
|
const jelly = createJelly((value) => {
|
|
1893
1901
|
state.squash = value;
|
|
1894
1902
|
paint();
|
|
1895
|
-
}, 0.
|
|
1896
|
-
const x = createSpring(current * slot,
|
|
1903
|
+
}, 0.2, 1200, WOBBLE);
|
|
1904
|
+
const x = createSpring(current * slot, LAND, (value, velocity) => {
|
|
1897
1905
|
state.x = value;
|
|
1898
1906
|
jelly.feed(velocity);
|
|
1899
1907
|
paint();
|
|
@@ -1911,8 +1919,10 @@ function useLensTrack(refs, options) {
|
|
|
1911
1919
|
paint();
|
|
1912
1920
|
});
|
|
1913
1921
|
const pull = (dy) => {
|
|
1922
|
+
if (!latest.current.pull) return;
|
|
1923
|
+
const toLayout = gesture ? bar.offsetHeight / Math.max(1, gesture.box.height) : 1;
|
|
1914
1924
|
pullY.tune(FOLLOW2);
|
|
1915
|
-
pullY.set(rubberband(dy
|
|
1925
|
+
pullY.set(rubberband(dy * toLayout, bar.offsetHeight * PULL_REACH, PULL_GIVE));
|
|
1916
1926
|
};
|
|
1917
1927
|
const letGo = () => {
|
|
1918
1928
|
pullY.tune(SPRINGS.release);
|
|
@@ -1921,7 +1931,7 @@ function useLensTrack(refs, options) {
|
|
|
1921
1931
|
const place = (index, instant = false) => {
|
|
1922
1932
|
current = index;
|
|
1923
1933
|
if (!gesture) {
|
|
1924
|
-
x.tune(
|
|
1934
|
+
x.tune(LAND);
|
|
1925
1935
|
x.set(index * slot, instant);
|
|
1926
1936
|
}
|
|
1927
1937
|
};
|
|
@@ -1961,7 +1971,7 @@ function useLensTrack(refs, options) {
|
|
|
1961
1971
|
lift.set(1);
|
|
1962
1972
|
swell.tune(SPRINGS.press);
|
|
1963
1973
|
swell.set(1);
|
|
1964
|
-
x.tune(
|
|
1974
|
+
x.tune(LAND);
|
|
1965
1975
|
x.set(index * slot);
|
|
1966
1976
|
paint();
|
|
1967
1977
|
};
|
|
@@ -1978,7 +1988,7 @@ function useLensTrack(refs, options) {
|
|
|
1978
1988
|
pull(event.clientY - gesture.startY);
|
|
1979
1989
|
if (!gesture.moved) return;
|
|
1980
1990
|
const at = position(event.clientX);
|
|
1981
|
-
x.tune(
|
|
1991
|
+
x.tune(DRAG);
|
|
1982
1992
|
x.set(at);
|
|
1983
1993
|
const hovered = clamp(Math.round(at / slot), 0, latest.current.count - 1);
|
|
1984
1994
|
if (hovered !== gesture.hovered) {
|
|
@@ -2007,7 +2017,7 @@ function useLensTrack(refs, options) {
|
|
|
2007
2017
|
swell.tune(SPRINGS.release);
|
|
2008
2018
|
swell.set(0);
|
|
2009
2019
|
letGo();
|
|
2010
|
-
x.tune(
|
|
2020
|
+
x.tune(LAND);
|
|
2011
2021
|
if (commit && (moved || inside)) {
|
|
2012
2022
|
suppressClick = true;
|
|
2013
2023
|
current = index;
|
|
@@ -2036,7 +2046,7 @@ function useLensTrack(refs, options) {
|
|
|
2036
2046
|
swell.tune(SPRINGS.release);
|
|
2037
2047
|
swell.set(0);
|
|
2038
2048
|
letGo();
|
|
2039
|
-
x.tune(
|
|
2049
|
+
x.tune(LAND);
|
|
2040
2050
|
x.set(current * slot);
|
|
2041
2051
|
};
|
|
2042
2052
|
const onClick = (event) => {
|
|
@@ -2152,7 +2162,9 @@ function LensTrack({
|
|
|
2152
2162
|
spread: tabbar ? 0.3 : 0.16,
|
|
2153
2163
|
contentZoom: zoom,
|
|
2154
2164
|
copied: true,
|
|
2155
|
-
swell: tabbar ?
|
|
2165
|
+
swell: tabbar ? 12 : 16,
|
|
2166
|
+
// The tab bar holds its place; only the segmented control gives.
|
|
2167
|
+
pull: !tabbar
|
|
2156
2168
|
}
|
|
2157
2169
|
);
|
|
2158
2170
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|