@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.mjs
CHANGED
|
@@ -129,8 +129,8 @@ var SPRINGS = {
|
|
|
129
129
|
/** A dragged lens's stretch: loose, so it wobbles when the drag stops. */
|
|
130
130
|
jelly: springFrom(0.3, 0.3)
|
|
131
131
|
};
|
|
132
|
-
function createJelly(onUpdate, max, speed) {
|
|
133
|
-
const spring = createSpring(0,
|
|
132
|
+
function createJelly(onUpdate, max, speed, config = SPRINGS.jelly) {
|
|
133
|
+
const spring = createSpring(0, config, (value) => onUpdate(value));
|
|
134
134
|
return {
|
|
135
135
|
feed(velocity) {
|
|
136
136
|
spring.set(max * Math.tanh(Math.abs(velocity) / speed));
|
|
@@ -626,7 +626,7 @@ function container() {
|
|
|
626
626
|
function canRefractBackdrop() {
|
|
627
627
|
if (typeof navigator === "undefined") return false;
|
|
628
628
|
const ua = navigator.userAgent;
|
|
629
|
-
return /Chrom(e|ium)\/|Edg\//.test(ua) && !/CriOS|FxiOS|EdgiOS/.test(ua);
|
|
629
|
+
return /Chrom(e|ium)\/|Edg\//.test(ua) && !/CriOS|FxiOS|EdgiOS|Android/.test(ua);
|
|
630
630
|
}
|
|
631
631
|
function bevelProfile(bezel, thickness, ior) {
|
|
632
632
|
const N = 256;
|
|
@@ -1702,6 +1702,11 @@ import { useRef as useRef7 } from "react";
|
|
|
1702
1702
|
// src/engine/lensTrack.ts
|
|
1703
1703
|
import { useEffect as useEffect5, useRef as useRef6 } from "react";
|
|
1704
1704
|
var FOLLOW2 = springFrom(0.2, 0.82);
|
|
1705
|
+
var PULL_REACH = 0.08;
|
|
1706
|
+
var PULL_GIVE = 0.15;
|
|
1707
|
+
var DRAG = springFrom(0.14, 0.84);
|
|
1708
|
+
var WOBBLE = springFrom(0.34, 0.2);
|
|
1709
|
+
var LAND = springFrom(0.38, 0.6);
|
|
1705
1710
|
function useLensTrack(refs, options) {
|
|
1706
1711
|
const latest = useRef6(options);
|
|
1707
1712
|
latest.current = options;
|
|
@@ -1774,15 +1779,18 @@ function useLensTrack(refs, options) {
|
|
|
1774
1779
|
if (!W || !H) return;
|
|
1775
1780
|
const kx = (slot + (W - slot) * lift2) / W * (1 + squash);
|
|
1776
1781
|
const ky = (height + (H - height) * lift2) / H * (1 - squash * 0.6);
|
|
1777
|
-
const grow = 1 + latest.current.swell / Math.max(bar.offsetWidth, 1) * swell2;
|
|
1778
1782
|
const pull2 = state.pull;
|
|
1779
|
-
const
|
|
1783
|
+
const h = Math.max(bar.offsetHeight, 1);
|
|
1784
|
+
const reach = Math.abs(pull2);
|
|
1785
|
+
const taken = clamp(reach / (h * PULL_REACH), 0, 1);
|
|
1786
|
+
const grow = 1 + latest.current.swell / Math.max(bar.offsetWidth, 1) * swell2 * (1 - taken * 0.85);
|
|
1787
|
+
const lean = Math.sign(pull2) * (reach / 2 + h * 0.03 * taken);
|
|
1780
1788
|
const transform = `translateX(${x2}px) scale(${kx}, ${ky})`;
|
|
1781
1789
|
lens.style.transform = transform;
|
|
1782
1790
|
select.style.transform = `translateX(${x2}px)`;
|
|
1783
1791
|
lens.style.opacity = String(clamp(lift2 * 4, 0, 1));
|
|
1784
|
-
shell.style.scale = `${grow * (1 -
|
|
1785
|
-
shell.style.translate = `0px ${
|
|
1792
|
+
shell.style.scale = `${grow * (1 - taken * 0.04)} ${grow + reach / h}`;
|
|
1793
|
+
shell.style.translate = `0px ${lean}px`;
|
|
1786
1794
|
lens.style.setProperty("--lg-lift", String(clamp(lift2, 0, 1)));
|
|
1787
1795
|
bar.style.setProperty("--lg-lift", String(clamp(lift2, 0, 1)));
|
|
1788
1796
|
for (const glyph of glyphs) {
|
|
@@ -1838,8 +1846,8 @@ function useLensTrack(refs, options) {
|
|
|
1838
1846
|
const jelly = createJelly((value) => {
|
|
1839
1847
|
state.squash = value;
|
|
1840
1848
|
paint();
|
|
1841
|
-
}, 0.
|
|
1842
|
-
const x = createSpring(current * slot,
|
|
1849
|
+
}, 0.2, 1200, WOBBLE);
|
|
1850
|
+
const x = createSpring(current * slot, LAND, (value, velocity) => {
|
|
1843
1851
|
state.x = value;
|
|
1844
1852
|
jelly.feed(velocity);
|
|
1845
1853
|
paint();
|
|
@@ -1857,8 +1865,10 @@ function useLensTrack(refs, options) {
|
|
|
1857
1865
|
paint();
|
|
1858
1866
|
});
|
|
1859
1867
|
const pull = (dy) => {
|
|
1868
|
+
if (!latest.current.pull) return;
|
|
1869
|
+
const toLayout = gesture ? bar.offsetHeight / Math.max(1, gesture.box.height) : 1;
|
|
1860
1870
|
pullY.tune(FOLLOW2);
|
|
1861
|
-
pullY.set(rubberband(dy
|
|
1871
|
+
pullY.set(rubberband(dy * toLayout, bar.offsetHeight * PULL_REACH, PULL_GIVE));
|
|
1862
1872
|
};
|
|
1863
1873
|
const letGo = () => {
|
|
1864
1874
|
pullY.tune(SPRINGS.release);
|
|
@@ -1867,7 +1877,7 @@ function useLensTrack(refs, options) {
|
|
|
1867
1877
|
const place = (index, instant = false) => {
|
|
1868
1878
|
current = index;
|
|
1869
1879
|
if (!gesture) {
|
|
1870
|
-
x.tune(
|
|
1880
|
+
x.tune(LAND);
|
|
1871
1881
|
x.set(index * slot, instant);
|
|
1872
1882
|
}
|
|
1873
1883
|
};
|
|
@@ -1907,7 +1917,7 @@ function useLensTrack(refs, options) {
|
|
|
1907
1917
|
lift.set(1);
|
|
1908
1918
|
swell.tune(SPRINGS.press);
|
|
1909
1919
|
swell.set(1);
|
|
1910
|
-
x.tune(
|
|
1920
|
+
x.tune(LAND);
|
|
1911
1921
|
x.set(index * slot);
|
|
1912
1922
|
paint();
|
|
1913
1923
|
};
|
|
@@ -1924,7 +1934,7 @@ function useLensTrack(refs, options) {
|
|
|
1924
1934
|
pull(event.clientY - gesture.startY);
|
|
1925
1935
|
if (!gesture.moved) return;
|
|
1926
1936
|
const at = position(event.clientX);
|
|
1927
|
-
x.tune(
|
|
1937
|
+
x.tune(DRAG);
|
|
1928
1938
|
x.set(at);
|
|
1929
1939
|
const hovered = clamp(Math.round(at / slot), 0, latest.current.count - 1);
|
|
1930
1940
|
if (hovered !== gesture.hovered) {
|
|
@@ -1953,7 +1963,7 @@ function useLensTrack(refs, options) {
|
|
|
1953
1963
|
swell.tune(SPRINGS.release);
|
|
1954
1964
|
swell.set(0);
|
|
1955
1965
|
letGo();
|
|
1956
|
-
x.tune(
|
|
1966
|
+
x.tune(LAND);
|
|
1957
1967
|
if (commit && (moved || inside)) {
|
|
1958
1968
|
suppressClick = true;
|
|
1959
1969
|
current = index;
|
|
@@ -1982,7 +1992,7 @@ function useLensTrack(refs, options) {
|
|
|
1982
1992
|
swell.tune(SPRINGS.release);
|
|
1983
1993
|
swell.set(0);
|
|
1984
1994
|
letGo();
|
|
1985
|
-
x.tune(
|
|
1995
|
+
x.tune(LAND);
|
|
1986
1996
|
x.set(current * slot);
|
|
1987
1997
|
};
|
|
1988
1998
|
const onClick = (event) => {
|
|
@@ -2098,7 +2108,9 @@ function LensTrack({
|
|
|
2098
2108
|
spread: tabbar ? 0.3 : 0.16,
|
|
2099
2109
|
contentZoom: zoom,
|
|
2100
2110
|
copied: true,
|
|
2101
|
-
swell: tabbar ?
|
|
2111
|
+
swell: tabbar ? 12 : 16,
|
|
2112
|
+
// The tab bar holds its place; only the segmented control gives.
|
|
2113
|
+
pull: !tabbar
|
|
2102
2114
|
}
|
|
2103
2115
|
);
|
|
2104
2116
|
return /* @__PURE__ */ jsxs5(
|