@zakisheriff/liquid-glass 0.3.11 → 0.3.13

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.js CHANGED
@@ -45,6 +45,7 @@ __export(index_exports, {
45
45
  canRefractBackdrop: () => canRefractBackdrop,
46
46
  createSpring: () => createSpring,
47
47
  haptic: () => haptic,
48
+ setGlassQuality: () => setGlassQuality,
48
49
  springFrom: () => springFrom,
49
50
  useGlassAnimation: () => useGlassAnimation,
50
51
  useGlassEffect: () => useGlassEffect,
@@ -74,9 +75,9 @@ function step(s, dt) {
74
75
  s.value = s.target + decay * (x + b * dt);
75
76
  s.velocity = decay * (v - half * b * dt);
76
77
  } else if (disc > 0) {
77
- const root = Math.sqrt(disc);
78
- const r1 = -half + root;
79
- const r2 = -half - root;
78
+ const root2 = Math.sqrt(disc);
79
+ const r1 = -half + root2;
80
+ const r2 = -half - root2;
80
81
  const a = (v - r2 * x) / (r1 - r2);
81
82
  const b = x - a;
82
83
  const e1 = Math.exp(r1 * dt);
@@ -331,9 +332,9 @@ var import_react2 = require("react");
331
332
  // src/engine/mirror.ts
332
333
  var SELF = "data-lg-mirror-self";
333
334
  function clone(source) {
334
- const root = source.cloneNode(true);
335
+ const root2 = source.cloneNode(true);
335
336
  const originals = [source, ...Array.from(source.querySelectorAll("*"))];
336
- const copies = [root, ...Array.from(root.querySelectorAll("*"))];
337
+ const copies = [root2, ...Array.from(root2.querySelectorAll("*"))];
337
338
  const pairs = [];
338
339
  originals.forEach((original, i) => {
339
340
  const copy = copies[i];
@@ -343,12 +344,12 @@ function clone(source) {
343
344
  if (copy instanceof HTMLImageElement) copy.loading = "eager";
344
345
  pairs.push({ original, copy, css: original.style.cssText, cls: original.className.toString() });
345
346
  });
346
- root.querySelectorAll(`[${SELF}], .lg-mirror, [data-lg-mirror-skip], input, textarea, select`).forEach((n) => n.remove());
347
- root.removeAttribute("data-mirror");
348
- root.setAttribute("data-lg-copy", "");
349
- root.setAttribute("inert", "");
350
- root.setAttribute("aria-hidden", "true");
351
- return { root, pairs };
347
+ root2.querySelectorAll(`[${SELF}], .lg-mirror, [data-lg-mirror-skip], input, textarea, select`).forEach((n) => n.remove());
348
+ root2.removeAttribute("data-mirror");
349
+ root2.setAttribute("data-lg-copy", "");
350
+ root2.setAttribute("inert", "");
351
+ root2.setAttribute("aria-hidden", "true");
352
+ return { root: root2, pairs };
352
353
  }
353
354
  var alpha = (color) => {
354
355
  const m = color.match(/rgba?\(([^)]+)\)/);
@@ -372,13 +373,13 @@ function backdropChain(glass, source) {
372
373
  var stateOf = (el2) => Array.from(el2.attributes).map((a) => a.name).filter((name) => name.startsWith("data-") && name !== "data-mirror" && !name.startsWith("data-lg-mirror")).sort().join(" ");
373
374
  var BACKGROUND = ["background-color", "background-image", "background-size", "background-position", "background-repeat", "border-radius"];
374
375
  var PLACEMENT = /* @__PURE__ */ new Set(["position", "left", "top", "margin", "margin-top", "margin-right", "margin-bottom", "margin-left", "width", "height", "max-width", "max-height", "min-width", "min-height", "scale", "translate", "transform-origin", "transform"]);
375
- function syncStyle(original, copy, root) {
376
+ function syncStyle(original, copy, root2) {
376
377
  for (const name of Array.from(copy.style)) {
377
- if (root && PLACEMENT.has(name)) continue;
378
+ if (root2 && PLACEMENT.has(name)) continue;
378
379
  if (!original.style.getPropertyValue(name)) copy.style.removeProperty(name);
379
380
  }
380
381
  for (const name of Array.from(original.style)) {
381
- if (root && PLACEMENT.has(name)) continue;
382
+ if (root2 && PLACEMENT.has(name)) continue;
382
383
  const value = original.style.getPropertyValue(name);
383
384
  const priority = original.style.getPropertyPriority(name);
384
385
  if (copy.style.getPropertyValue(name) !== value || copy.style.getPropertyPriority(name) !== priority) {
@@ -461,21 +462,21 @@ function mirrorBackdrop(glass, source, padding, zoom, active2 = () => true) {
461
462
  const next = at.key;
462
463
  if (next === placed) return;
463
464
  placed = next;
464
- const root = copy.root;
465
- root.style.position = "absolute";
466
- root.style.left = "0px";
467
- root.style.top = "0px";
468
- root.style.margin = "0px";
469
- root.style.width = `${sw}px`;
470
- root.style.height = `${sh}px`;
471
- root.style.maxWidth = "none";
472
- root.style.maxHeight = "none";
473
- root.style.minWidth = "0px";
474
- root.style.minHeight = "0px";
475
- root.style.scale = "none";
476
- root.style.translate = "none";
477
- root.style.transformOrigin = "0 0";
478
- root.style.transform = at.transform;
465
+ const root2 = copy.root;
466
+ root2.style.position = "absolute";
467
+ root2.style.left = "0px";
468
+ root2.style.top = "0px";
469
+ root2.style.margin = "0px";
470
+ root2.style.width = `${sw}px`;
471
+ root2.style.height = `${sh}px`;
472
+ root2.style.maxWidth = "none";
473
+ root2.style.maxHeight = "none";
474
+ root2.style.minWidth = "0px";
475
+ root2.style.minHeight = "0px";
476
+ root2.style.scale = "none";
477
+ root2.style.translate = "none";
478
+ root2.style.transformOrigin = "0 0";
479
+ root2.style.transform = at.transform;
479
480
  };
480
481
  const sync = () => {
481
482
  for (const pair of copy.pairs) {
@@ -565,6 +566,98 @@ function mirrorBackdrop(glass, source, padding, zoom, active2 = () => true) {
565
566
  };
566
567
  }
567
568
 
569
+ // src/engine/quality.ts
570
+ var started = false;
571
+ var pinned = "auto";
572
+ var probing = false;
573
+ var offscreen = null;
574
+ var root = () => document.documentElement;
575
+ function apply(level) {
576
+ if (root().getAttribute("data-lg-quality") !== level) root().setAttribute("data-lg-quality", level);
577
+ }
578
+ function guess() {
579
+ const nav = navigator;
580
+ if (typeof nav.deviceMemory === "number" && nav.deviceMemory <= 4) return "low";
581
+ if (typeof nav.hardwareConcurrency === "number" && nav.hardwareConcurrency <= 4) return "low";
582
+ return "high";
583
+ }
584
+ function probe() {
585
+ if (probing || pinned !== "auto" || root().getAttribute("data-lg-quality") === "low") return;
586
+ probing = true;
587
+ const gaps = [];
588
+ let last2 = 0;
589
+ let frame2 = 0;
590
+ const end = performance.now() + 2e3;
591
+ const step2 = (now) => {
592
+ if (last2) gaps.push(now - last2);
593
+ last2 = now;
594
+ if (now < end && gaps.length < 120) {
595
+ frame2 = requestAnimationFrame(step2);
596
+ return;
597
+ }
598
+ probing = false;
599
+ if (gaps.length < 20 || pinned !== "auto") return;
600
+ const slow = gaps.filter((gap) => gap > 26).length / gaps.length;
601
+ if (slow > 0.2) apply("low");
602
+ };
603
+ frame2 = requestAnimationFrame(step2);
604
+ void frame2;
605
+ }
606
+ function watchScroll() {
607
+ let timer = 0;
608
+ let probes = 0;
609
+ const settle = () => {
610
+ timer = 0;
611
+ root().removeAttribute("data-lg-scrolling");
612
+ };
613
+ const onScroll = () => {
614
+ if (!timer) {
615
+ root().setAttribute("data-lg-scrolling", "");
616
+ if (probes < 2) {
617
+ probes++;
618
+ probe();
619
+ }
620
+ } else {
621
+ clearTimeout(timer);
622
+ }
623
+ timer = window.setTimeout(settle, 140);
624
+ };
625
+ document.addEventListener("scroll", onScroll, { capture: true, passive: true });
626
+ }
627
+ function start() {
628
+ if (started || typeof window === "undefined") return;
629
+ started = true;
630
+ apply(pinned === "auto" ? guess() : pinned);
631
+ watchScroll();
632
+ if (typeof IntersectionObserver === "function") {
633
+ offscreen = new IntersectionObserver(
634
+ (entries) => {
635
+ for (const entry of entries) {
636
+ const el2 = entry.target;
637
+ if (entry.isIntersecting) el2.removeAttribute("data-lg-offscreen");
638
+ else el2.setAttribute("data-lg-offscreen", "");
639
+ }
640
+ },
641
+ // Turn back on a little before it scrolls into view.
642
+ { rootMargin: "25% 0px" }
643
+ );
644
+ }
645
+ }
646
+ function governRefraction(element) {
647
+ start();
648
+ offscreen?.observe(element);
649
+ return () => {
650
+ offscreen?.unobserve(element);
651
+ element.removeAttribute("data-lg-offscreen");
652
+ };
653
+ }
654
+ function setGlassQuality(quality) {
655
+ pinned = quality;
656
+ if (typeof window === "undefined") return;
657
+ if (!started) start();
658
+ apply(quality === "auto" ? guess() : quality);
659
+ }
660
+
568
661
  // src/engine/refraction.ts
569
662
  var SVG_NS = "http://www.w3.org/2000/svg";
570
663
  var cache = /* @__PURE__ */ new Map();
@@ -577,11 +670,11 @@ function el(name, attrs) {
577
670
  }
578
671
  function container() {
579
672
  if (defs?.isConnected) return defs;
580
- const root = el("svg", { width: 0, height: 0, "aria-hidden": "true", "data-liquid-glass-defs": "" });
581
- root.style.cssText = "position:absolute;width:0;height:0;overflow:hidden;pointer-events:none";
673
+ const root2 = el("svg", { width: 0, height: 0, "aria-hidden": "true", "data-liquid-glass-defs": "" });
674
+ root2.style.cssText = "position:absolute;width:0;height:0;overflow:hidden;pointer-events:none";
582
675
  defs = el("defs", {});
583
- root.append(defs);
584
- document.body.append(root);
676
+ root2.append(defs);
677
+ document.body.append(root2);
585
678
  return defs;
586
679
  }
587
680
  function canRefractBackdrop() {
@@ -640,6 +733,7 @@ function bake(width, height, radius, shape, pad = 0, simple = false, fringe = fa
640
733
  const t = clamp((Math.abs(py) - (edge - 2)) / 3, 0, 1);
641
734
  return 1 - t * t * (3 - 2 * t);
642
735
  };
736
+ const flat = simple && magnify ? Infinity : Math.max(shape.bezel * 1.7, 5);
643
737
  for (let y = 0; y < ch; y++) {
644
738
  for (let x = 0; x < cw; x++) {
645
739
  const px = (x + 0.5) * W / cw - W / 2;
@@ -650,6 +744,10 @@ function bake(width, height, radius, shape, pad = 0, simple = false, fringe = fa
650
744
  const oy = Math.max(qy, 0);
651
745
  const len = Math.hypot(ox, oy);
652
746
  const d = radius - (len + Math.min(Math.max(qx, qy), 0));
747
+ if (d > flat) {
748
+ inside[y * cw + x] = 1;
749
+ continue;
750
+ }
653
751
  let nx;
654
752
  let ny;
655
753
  if (len > 0) {
@@ -856,9 +954,12 @@ function bake(width, height, radius, shape, pad = 0, simple = false, fringe = fa
856
954
  );
857
955
  }
858
956
  let out = "bent";
957
+ const soften = shape.stretch > 0 ? 1.1 : 0.65;
859
958
  if (smooth) {
860
959
  filter.append(
861
- el("feGaussianBlur", { in: "bent", stdDeviation: box ? `${0.65 / W} ${0.65 / H}` : 0.65, result: "bent-soft" }),
960
+ // A stretched rim magnifies the pixel steps of whatever edge it smears,
961
+ // so it gets a little more softening.
962
+ el("feGaussianBlur", { in: "bent", stdDeviation: box ? `${soften / W} ${soften / H}` : soften, result: "bent-soft" }),
862
963
  el("feImage", { href: smooth, ...area, preserveAspectRatio: "none", result: "rim-zone" }),
863
964
  el("feComposite", { in: "bent-soft", in2: "rim-zone", operator: "in", result: "rim-soft" }),
864
965
  el("feComposite", { in: "bent", in2: "rim-zone", operator: "out", result: "core" }),
@@ -904,6 +1005,34 @@ function glassFor(width, height, radius, shape = {}, pad = 0, simple = false, fr
904
1005
  }
905
1006
  return baked;
906
1007
  }
1008
+ var soon = [];
1009
+ var later = [];
1010
+ var pumping = false;
1011
+ function pump() {
1012
+ pumping = true;
1013
+ const run = (deadline) => {
1014
+ const end = performance.now() + 8;
1015
+ const left = () => deadline ? deadline.timeRemaining() > 4 : performance.now() < end;
1016
+ let ran = 0;
1017
+ while ((soon.length || later.length) && (ran === 0 || left())) {
1018
+ (soon.shift() ?? later.shift())();
1019
+ ran++;
1020
+ }
1021
+ if (soon.length || later.length) idle(run);
1022
+ else pumping = false;
1023
+ };
1024
+ idle(run);
1025
+ }
1026
+ function bakeSoon(job, urgent = true) {
1027
+ (urgent ? soon : later).push(job);
1028
+ if (!pumping) pump();
1029
+ return () => {
1030
+ for (const list of [soon, later]) {
1031
+ const at = list.indexOf(job);
1032
+ if (at >= 0) list.splice(at, 1);
1033
+ }
1034
+ };
1035
+ }
907
1036
  function idle(callback) {
908
1037
  if (typeof requestIdleCallback === "function") {
909
1038
  const handle2 = requestIdleCallback(callback, { timeout: 120 });
@@ -954,28 +1083,44 @@ function useRefraction(ref, shape = {}, enabled = true, mirror, mirrorActive) {
954
1083
  }
955
1084
  if (live || bendCopy && chromium) {
956
1085
  const backdrop = live ? baked.filter : glassFor(width, height, radius, { ...shape, zoom: 1, zoomX: 1, strength: (shape.strength ?? 1) * 0.45 }).filter;
957
- element.style.setProperty("--lg-filter", backdrop);
958
- element.setAttribute("data-lg-refract", "");
1086
+ element.style.setProperty("--lg-refraction", backdrop);
1087
+ element.setAttribute("data-lg-refract", shape.kind ?? "surface");
959
1088
  }
960
1089
  element.style.setProperty("--lg-rim", baked.rim);
961
1090
  };
1091
+ let seen = typeof IntersectionObserver !== "function";
1092
+ const request = () => {
1093
+ cancel?.();
1094
+ cancel = bakeSoon(fit, seen);
1095
+ };
1096
+ const near = typeof IntersectionObserver === "function" ? new IntersectionObserver(
1097
+ (entries) => {
1098
+ if (!entries.some((entry) => entry.isIntersecting)) return;
1099
+ seen = true;
1100
+ near?.disconnect();
1101
+ request();
1102
+ },
1103
+ { rootMargin: "100% 0px" }
1104
+ ) : null;
1105
+ near?.observe(element);
962
1106
  const observer = new ResizeObserver(() => {
963
1107
  cancel?.();
964
- const timer = setTimeout(() => {
965
- cancel = idle(fit);
966
- }, 140);
1108
+ const timer = setTimeout(request, 140);
967
1109
  cancel = () => clearTimeout(timer);
968
1110
  });
969
1111
  observer.observe(element);
970
- fit();
1112
+ request();
971
1113
  const source = mirror?.current;
972
1114
  const unmirror = !live && source ? mirrorBackdrop(element, source, () => pad, () => [zoomX, zoom], mirrorActive) : void 0;
973
1115
  applyCopyFilter();
1116
+ const ungovern = governRefraction(element);
974
1117
  return () => {
975
1118
  cancel?.();
976
1119
  unmirror?.();
1120
+ ungovern();
1121
+ near?.disconnect();
977
1122
  observer.disconnect();
978
- element.style.removeProperty("--lg-filter");
1123
+ element.style.removeProperty("--lg-refraction");
979
1124
  element.style.removeProperty("--lg-rim");
980
1125
  element.removeAttribute("data-lg-refract");
981
1126
  };
@@ -1610,6 +1755,7 @@ var import_react9 = require("react");
1610
1755
 
1611
1756
  // src/engine/lensTrack.ts
1612
1757
  var import_react8 = require("react");
1758
+ var FOLLOW2 = springFrom(0.2, 0.82);
1613
1759
  function useLensTrack(refs, options) {
1614
1760
  const latest = (0, import_react8.useRef)(options);
1615
1761
  latest.current = options;
@@ -1620,13 +1766,15 @@ function useLensTrack(refs, options) {
1620
1766
  const glass = refs.glass.current;
1621
1767
  const select = refs.select.current;
1622
1768
  if (!bar || !lens || !glass || !select) return;
1769
+ const parent = bar.parentElement;
1770
+ const shell = parent?.classList.contains("lg-glass") && parent.childElementCount === 1 ? parent : bar;
1623
1771
  let slot = 0;
1624
1772
  let height = 0;
1625
1773
  let pad = 0;
1626
1774
  let padY = 0;
1627
1775
  let W = 0;
1628
1776
  let H = 0;
1629
- const state = { x: 0, lift: 0, swell: 0, squash: 0 };
1777
+ const state = { x: 0, lift: 0, swell: 0, squash: 0, pull: 0 };
1630
1778
  let current = latest.current.index;
1631
1779
  let gesture = null;
1632
1780
  let dropTimer = 0;
@@ -1681,11 +1829,14 @@ function useLensTrack(refs, options) {
1681
1829
  const kx = (slot + (W - slot) * lift2) / W * (1 + squash);
1682
1830
  const ky = (height + (H - height) * lift2) / H * (1 - squash * 0.6);
1683
1831
  const grow = 1 + latest.current.swell / Math.max(bar.offsetWidth, 1) * swell2;
1832
+ const pull2 = state.pull;
1833
+ const ey = Math.abs(pull2) / Math.max(bar.offsetHeight, 1);
1684
1834
  const transform = `translateX(${x2}px) scale(${kx}, ${ky})`;
1685
1835
  lens.style.transform = transform;
1686
1836
  select.style.transform = `translateX(${x2}px)`;
1687
1837
  lens.style.opacity = String(clamp(lift2 * 4, 0, 1));
1688
- bar.style.scale = `${grow}`;
1838
+ shell.style.scale = `${grow * (1 - ey * 0.15)} ${grow * (1 + ey * 0.5)}`;
1839
+ shell.style.translate = `0px ${pull2 / 2}px`;
1689
1840
  lens.style.setProperty("--lg-lift", String(clamp(lift2, 0, 1)));
1690
1841
  bar.style.setProperty("--lg-lift", String(clamp(lift2, 0, 1)));
1691
1842
  for (const glyph of glyphs) {
@@ -1755,6 +1906,18 @@ function useLensTrack(refs, options) {
1755
1906
  state.swell = value;
1756
1907
  paint();
1757
1908
  });
1909
+ const pullY = createSpring(0, SPRINGS.release, (value) => {
1910
+ state.pull = value;
1911
+ paint();
1912
+ });
1913
+ const pull = (dy) => {
1914
+ pullY.tune(FOLLOW2);
1915
+ pullY.set(rubberband(dy, Math.min(10, bar.offsetHeight * 0.2), 0.5));
1916
+ };
1917
+ const letGo = () => {
1918
+ pullY.tune(SPRINGS.release);
1919
+ pullY.set(0);
1920
+ };
1758
1921
  const place = (index, instant = false) => {
1759
1922
  current = index;
1760
1923
  if (!gesture) {
@@ -1787,7 +1950,7 @@ function useLensTrack(refs, options) {
1787
1950
  clearTimeout(dropTimer);
1788
1951
  measure();
1789
1952
  const box = bar.getBoundingClientRect();
1790
- gesture = { id: event.pointerId, startX: event.clientX, anchor: index * slot, moved: false, box, hovered: index, startedAt: performance.now() };
1953
+ gesture = { id: event.pointerId, startX: event.clientX, startY: event.clientY, anchor: index * slot, moved: false, box, hovered: index, startedAt: performance.now() };
1791
1954
  suppressClick = false;
1792
1955
  bar.dataset.lifted = "";
1793
1956
  preview(index);
@@ -1812,6 +1975,7 @@ function useLensTrack(refs, options) {
1812
1975
  }
1813
1976
  }
1814
1977
  light(event.clientX, gesture.box);
1978
+ pull(event.clientY - gesture.startY);
1815
1979
  if (!gesture.moved) return;
1816
1980
  const at = position(event.clientX);
1817
1981
  x.tune(SPRINGS.drag);
@@ -1842,6 +2006,7 @@ function useLensTrack(refs, options) {
1842
2006
  else drop();
1843
2007
  swell.tune(SPRINGS.release);
1844
2008
  swell.set(0);
2009
+ letGo();
1845
2010
  x.tune(SPRINGS.snap);
1846
2011
  if (commit && (moved || inside)) {
1847
2012
  suppressClick = true;
@@ -1870,6 +2035,7 @@ function useLensTrack(refs, options) {
1870
2035
  lift.set(0);
1871
2036
  swell.tune(SPRINGS.release);
1872
2037
  swell.set(0);
2038
+ letGo();
1873
2039
  x.tune(SPRINGS.snap);
1874
2040
  x.set(current * slot);
1875
2041
  };
@@ -1919,7 +2085,9 @@ function useLensTrack(refs, options) {
1919
2085
  return () => {
1920
2086
  clearTimeout(dropTimer);
1921
2087
  api.current = null;
1922
- [x, lift, swell, jelly].forEach((s) => s.stop());
2088
+ [x, lift, swell, pullY, jelly].forEach((s) => s.stop());
2089
+ shell.style.removeProperty("scale");
2090
+ shell.style.removeProperty("translate");
1923
2091
  unguard();
1924
2092
  observer.disconnect();
1925
2093
  bar.removeEventListener("pointerdown", onDown);
@@ -2118,7 +2286,7 @@ var GlassSlider = import_react12.default.forwardRef(
2118
2286
  (0, import_react12.useImperativeHandle)(forwardedRef, () => inputRef.current);
2119
2287
  (0, import_react12.useEffect)(() => {
2120
2288
  const input2 = inputRef.current;
2121
- const root = rootRef.current;
2289
+ const root2 = rootRef.current;
2122
2290
  const setValue = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value").set;
2123
2291
  let drag = null;
2124
2292
  const update = (clientX) => {
@@ -2132,7 +2300,7 @@ var GlassSlider = import_react12.default.forwardRef(
2132
2300
  next = clamp(min + Math.round((next - min) / increment) * increment, min, max);
2133
2301
  next = Number(next.toFixed(10));
2134
2302
  }
2135
- root.style.setProperty("--lg-progress", String((next - min) / (max - min)));
2303
+ root2.style.setProperty("--lg-progress", String((next - min) / (max - min)));
2136
2304
  if (next === input2.valueAsNumber) return;
2137
2305
  setValue.call(input2, String(next));
2138
2306
  input2.dispatchEvent(new Event("input", { bubbles: true }));
@@ -2140,15 +2308,15 @@ var GlassSlider = import_react12.default.forwardRef(
2140
2308
  const down = (event) => {
2141
2309
  if (input2.disabled || !event.isPrimary || event.button !== 0 || drag) return;
2142
2310
  event.preventDefault();
2143
- delete root.dataset.keyboard;
2311
+ delete root2.dataset.keyboard;
2144
2312
  if (event.pointerType !== "touch") input2.focus({ preventScroll: true });
2145
- const box = root.getBoundingClientRect();
2146
- const inset = showThumb ? 19 * box.width / root.offsetWidth : 0;
2313
+ const box = root2.getBoundingClientRect();
2314
+ const inset = showThumb ? 19 * box.width / root2.offsetWidth : 0;
2147
2315
  const from = max > min ? clamp((input2.valueAsNumber - min) / (max - min), 0, 1) : 0;
2148
2316
  drag = { id: event.pointerId, x: event.clientX, from, travel: Math.max(1, box.width - inset * 2) };
2149
2317
  pastRef.current = 0;
2150
- root.dataset.dragging = "";
2151
- root.setPointerCapture(event.pointerId);
2318
+ root2.dataset.dragging = "";
2319
+ root2.setPointerCapture(event.pointerId);
2152
2320
  };
2153
2321
  const move = (event) => {
2154
2322
  if (event.pointerId !== drag?.id) return;
@@ -2160,29 +2328,29 @@ var GlassSlider = import_react12.default.forwardRef(
2160
2328
  const id = drag.id;
2161
2329
  drag = null;
2162
2330
  pastRef.current = 0;
2163
- delete root.dataset.dragging;
2164
- if (root.hasPointerCapture(id)) root.releasePointerCapture(id);
2331
+ delete root2.dataset.dragging;
2332
+ if (root2.hasPointerCapture(id)) root2.releasePointerCapture(id);
2165
2333
  };
2166
2334
  const up = (event) => {
2167
2335
  if (event.pointerId !== drag?.id) return;
2168
2336
  update(event.clientX);
2169
2337
  release();
2170
2338
  };
2171
- const unguard = guardSelection(root);
2172
- root.addEventListener("pointerdown", down);
2173
- root.addEventListener("pointermove", move);
2174
- root.addEventListener("pointerup", up);
2175
- root.addEventListener("pointercancel", release);
2176
- root.addEventListener("lostpointercapture", release);
2339
+ const unguard = guardSelection(root2);
2340
+ root2.addEventListener("pointerdown", down);
2341
+ root2.addEventListener("pointermove", move);
2342
+ root2.addEventListener("pointerup", up);
2343
+ root2.addEventListener("pointercancel", release);
2344
+ root2.addEventListener("lostpointercapture", release);
2177
2345
  window.addEventListener("blur", release);
2178
2346
  return () => {
2179
2347
  release();
2180
2348
  unguard();
2181
- root.removeEventListener("pointerdown", down);
2182
- root.removeEventListener("pointermove", move);
2183
- root.removeEventListener("pointerup", up);
2184
- root.removeEventListener("pointercancel", release);
2185
- root.removeEventListener("lostpointercapture", release);
2349
+ root2.removeEventListener("pointerdown", down);
2350
+ root2.removeEventListener("pointermove", move);
2351
+ root2.removeEventListener("pointerup", up);
2352
+ root2.removeEventListener("pointercancel", release);
2353
+ root2.removeEventListener("lostpointercapture", release);
2186
2354
  window.removeEventListener("blur", release);
2187
2355
  };
2188
2356
  }, [min, max, step2, showThumb]);
@@ -2203,16 +2371,16 @@ var GlassSlider = import_react12.default.forwardRef(
2203
2371
  const input2 = inputRef.current;
2204
2372
  const thumb = thumbRef.current;
2205
2373
  const face = faceRef.current;
2206
- const root = rootRef.current;
2374
+ const root2 = rootRef.current;
2207
2375
  const v = { lift: 0, stretch: 0, over: 0 };
2208
2376
  const paint = () => {
2209
2377
  const s = 0.655 + 0.345 * v.lift;
2210
2378
  const pull = Math.abs(v.over) / 58 * 0.6;
2211
2379
  thumb.style.scale = `${s * (1 + v.stretch + pull)} ${s * (1 - v.stretch * 0.5 - pull * 0.4)}`;
2212
2380
  face.style.opacity = String(1 - clamp(v.lift, 0, 1) * 0.92);
2213
- root.style.setProperty("--lg-lift", String(clamp(v.lift, 0, 1)));
2214
- root.style.setProperty("--lg-over", `${v.over.toFixed(2)}px`);
2215
- if (v.lift < 0.01 && lift.target === 0) delete root.dataset.lifted;
2381
+ root2.style.setProperty("--lg-lift", String(clamp(v.lift, 0, 1)));
2382
+ root2.style.setProperty("--lg-over", `${v.over.toFixed(2)}px`);
2383
+ if (v.lift < 0.01 && lift.target === 0) delete root2.dataset.lifted;
2216
2384
  };
2217
2385
  const lift = createSpring(0, SPRINGS.lift, (x) => {
2218
2386
  v.lift = x;
@@ -2233,7 +2401,7 @@ var GlassSlider = import_react12.default.forwardRef(
2233
2401
  if (input2.disabled || !event.isPrimary || event.button !== 0) return;
2234
2402
  lastX = event.clientX;
2235
2403
  lastT = event.timeStamp;
2236
- root.dataset.lifted = "";
2404
+ root2.dataset.lifted = "";
2237
2405
  lift.tune(SPRINGS.lift);
2238
2406
  lift.set(1);
2239
2407
  haptic();
@@ -2258,30 +2426,30 @@ var GlassSlider = import_react12.default.forwardRef(
2258
2426
  over.tune(SPRINGS.release);
2259
2427
  over.set(0);
2260
2428
  };
2261
- root.addEventListener("pointerdown", down);
2429
+ root2.addEventListener("pointerdown", down);
2262
2430
  window.addEventListener("pointermove", move);
2263
2431
  window.addEventListener("pointerup", up);
2264
2432
  window.addEventListener("pointercancel", up);
2265
- root.addEventListener("lostpointercapture", up);
2433
+ root2.addEventListener("lostpointercapture", up);
2266
2434
  window.addEventListener("blur", up);
2267
2435
  return () => {
2268
2436
  lift.stop();
2269
2437
  stretch.stop();
2270
2438
  over.stop();
2271
- root.removeEventListener("pointerdown", down);
2439
+ root2.removeEventListener("pointerdown", down);
2272
2440
  window.removeEventListener("pointermove", move);
2273
2441
  window.removeEventListener("pointerup", up);
2274
2442
  window.removeEventListener("pointercancel", up);
2275
- root.removeEventListener("lostpointercapture", up);
2443
+ root2.removeEventListener("lostpointercapture", up);
2276
2444
  window.removeEventListener("blur", up);
2277
- delete root.dataset.lifted;
2445
+ delete root2.dataset.lifted;
2278
2446
  };
2279
2447
  }, [showThumb]);
2280
2448
  (0, import_react12.useEffect)(() => {
2281
2449
  if (showThumb) return;
2282
2450
  const input2 = inputRef.current;
2283
2451
  const block = blockRef.current;
2284
- const root = rootRef.current;
2452
+ const root2 = rootRef.current;
2285
2453
  const v = { swell: 0, over: 0 };
2286
2454
  const paint = () => {
2287
2455
  const w = block.offsetWidth || 1;
@@ -2322,8 +2490,8 @@ var GlassSlider = import_react12.default.forwardRef(
2322
2490
  const up = (event) => {
2323
2491
  if (event.pointerId === active2?.id) reset();
2324
2492
  };
2325
- root.addEventListener("pointerdown", down);
2326
- root.addEventListener("lostpointercapture", reset);
2493
+ root2.addEventListener("pointerdown", down);
2494
+ root2.addEventListener("lostpointercapture", reset);
2327
2495
  window.addEventListener("blur", reset);
2328
2496
  window.addEventListener("pointermove", move);
2329
2497
  window.addEventListener("pointerup", up);
@@ -2331,8 +2499,8 @@ var GlassSlider = import_react12.default.forwardRef(
2331
2499
  return () => {
2332
2500
  swell.stop();
2333
2501
  over.stop();
2334
- root.removeEventListener("pointerdown", down);
2335
- root.removeEventListener("lostpointercapture", reset);
2502
+ root2.removeEventListener("pointerdown", down);
2503
+ root2.removeEventListener("lostpointercapture", reset);
2336
2504
  window.removeEventListener("blur", reset);
2337
2505
  window.removeEventListener("pointermove", move);
2338
2506
  window.removeEventListener("pointerup", up);
@@ -2432,7 +2600,7 @@ var GlassSwitch = import_react13.default.forwardRef(
2432
2600
  const sync = (0, import_react13.useRef)(null);
2433
2601
  useRefraction(
2434
2602
  thumbRef,
2435
- { kind: "lens", zoom: 0.72, zoomX: 1, dispersion: 1, stretch: 1, copy: "refract", strength: Math.max(1, Math.min(10, intensity)) / 5 },
2603
+ { kind: "lens", zoom: 0.72, zoomX: 1, dispersion: 0, stretch: 1, copy: "refract", strength: Math.max(1, Math.min(10, intensity)) / 5 },
2436
2604
  true,
2437
2605
  ref,
2438
2606
  () => parseFloat(ref.current?.style.getPropertyValue("--lg-lift") || "0") > 0.01
@@ -2766,6 +2934,7 @@ function useGlassAnimation() {
2766
2934
  canRefractBackdrop,
2767
2935
  createSpring,
2768
2936
  haptic,
2937
+ setGlassQuality,
2769
2938
  springFrom,
2770
2939
  useGlassAnimation,
2771
2940
  useGlassEffect,