@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.mjs CHANGED
@@ -21,9 +21,9 @@ function step(s, dt) {
21
21
  s.value = s.target + decay * (x + b * dt);
22
22
  s.velocity = decay * (v - half * b * dt);
23
23
  } else if (disc > 0) {
24
- const root = Math.sqrt(disc);
25
- const r1 = -half + root;
26
- const r2 = -half - root;
24
+ const root2 = Math.sqrt(disc);
25
+ const r1 = -half + root2;
26
+ const r2 = -half - root2;
27
27
  const a = (v - r2 * x) / (r1 - r2);
28
28
  const b = x - a;
29
29
  const e1 = Math.exp(r1 * dt);
@@ -278,9 +278,9 @@ import { useEffect as useEffect2 } from "react";
278
278
  // src/engine/mirror.ts
279
279
  var SELF = "data-lg-mirror-self";
280
280
  function clone(source) {
281
- const root = source.cloneNode(true);
281
+ const root2 = source.cloneNode(true);
282
282
  const originals = [source, ...Array.from(source.querySelectorAll("*"))];
283
- const copies = [root, ...Array.from(root.querySelectorAll("*"))];
283
+ const copies = [root2, ...Array.from(root2.querySelectorAll("*"))];
284
284
  const pairs = [];
285
285
  originals.forEach((original, i) => {
286
286
  const copy = copies[i];
@@ -290,12 +290,12 @@ function clone(source) {
290
290
  if (copy instanceof HTMLImageElement) copy.loading = "eager";
291
291
  pairs.push({ original, copy, css: original.style.cssText, cls: original.className.toString() });
292
292
  });
293
- root.querySelectorAll(`[${SELF}], .lg-mirror, [data-lg-mirror-skip], input, textarea, select`).forEach((n) => n.remove());
294
- root.removeAttribute("data-mirror");
295
- root.setAttribute("data-lg-copy", "");
296
- root.setAttribute("inert", "");
297
- root.setAttribute("aria-hidden", "true");
298
- return { root, pairs };
293
+ root2.querySelectorAll(`[${SELF}], .lg-mirror, [data-lg-mirror-skip], input, textarea, select`).forEach((n) => n.remove());
294
+ root2.removeAttribute("data-mirror");
295
+ root2.setAttribute("data-lg-copy", "");
296
+ root2.setAttribute("inert", "");
297
+ root2.setAttribute("aria-hidden", "true");
298
+ return { root: root2, pairs };
299
299
  }
300
300
  var alpha = (color) => {
301
301
  const m = color.match(/rgba?\(([^)]+)\)/);
@@ -319,13 +319,13 @@ function backdropChain(glass, source) {
319
319
  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(" ");
320
320
  var BACKGROUND = ["background-color", "background-image", "background-size", "background-position", "background-repeat", "border-radius"];
321
321
  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"]);
322
- function syncStyle(original, copy, root) {
322
+ function syncStyle(original, copy, root2) {
323
323
  for (const name of Array.from(copy.style)) {
324
- if (root && PLACEMENT.has(name)) continue;
324
+ if (root2 && PLACEMENT.has(name)) continue;
325
325
  if (!original.style.getPropertyValue(name)) copy.style.removeProperty(name);
326
326
  }
327
327
  for (const name of Array.from(original.style)) {
328
- if (root && PLACEMENT.has(name)) continue;
328
+ if (root2 && PLACEMENT.has(name)) continue;
329
329
  const value = original.style.getPropertyValue(name);
330
330
  const priority = original.style.getPropertyPriority(name);
331
331
  if (copy.style.getPropertyValue(name) !== value || copy.style.getPropertyPriority(name) !== priority) {
@@ -408,21 +408,21 @@ function mirrorBackdrop(glass, source, padding, zoom, active2 = () => true) {
408
408
  const next = at.key;
409
409
  if (next === placed) return;
410
410
  placed = next;
411
- const root = copy.root;
412
- root.style.position = "absolute";
413
- root.style.left = "0px";
414
- root.style.top = "0px";
415
- root.style.margin = "0px";
416
- root.style.width = `${sw}px`;
417
- root.style.height = `${sh}px`;
418
- root.style.maxWidth = "none";
419
- root.style.maxHeight = "none";
420
- root.style.minWidth = "0px";
421
- root.style.minHeight = "0px";
422
- root.style.scale = "none";
423
- root.style.translate = "none";
424
- root.style.transformOrigin = "0 0";
425
- root.style.transform = at.transform;
411
+ const root2 = copy.root;
412
+ root2.style.position = "absolute";
413
+ root2.style.left = "0px";
414
+ root2.style.top = "0px";
415
+ root2.style.margin = "0px";
416
+ root2.style.width = `${sw}px`;
417
+ root2.style.height = `${sh}px`;
418
+ root2.style.maxWidth = "none";
419
+ root2.style.maxHeight = "none";
420
+ root2.style.minWidth = "0px";
421
+ root2.style.minHeight = "0px";
422
+ root2.style.scale = "none";
423
+ root2.style.translate = "none";
424
+ root2.style.transformOrigin = "0 0";
425
+ root2.style.transform = at.transform;
426
426
  };
427
427
  const sync = () => {
428
428
  for (const pair of copy.pairs) {
@@ -512,6 +512,98 @@ function mirrorBackdrop(glass, source, padding, zoom, active2 = () => true) {
512
512
  };
513
513
  }
514
514
 
515
+ // src/engine/quality.ts
516
+ var started = false;
517
+ var pinned = "auto";
518
+ var probing = false;
519
+ var offscreen = null;
520
+ var root = () => document.documentElement;
521
+ function apply(level) {
522
+ if (root().getAttribute("data-lg-quality") !== level) root().setAttribute("data-lg-quality", level);
523
+ }
524
+ function guess() {
525
+ const nav = navigator;
526
+ if (typeof nav.deviceMemory === "number" && nav.deviceMemory <= 4) return "low";
527
+ if (typeof nav.hardwareConcurrency === "number" && nav.hardwareConcurrency <= 4) return "low";
528
+ return "high";
529
+ }
530
+ function probe() {
531
+ if (probing || pinned !== "auto" || root().getAttribute("data-lg-quality") === "low") return;
532
+ probing = true;
533
+ const gaps = [];
534
+ let last2 = 0;
535
+ let frame2 = 0;
536
+ const end = performance.now() + 2e3;
537
+ const step2 = (now) => {
538
+ if (last2) gaps.push(now - last2);
539
+ last2 = now;
540
+ if (now < end && gaps.length < 120) {
541
+ frame2 = requestAnimationFrame(step2);
542
+ return;
543
+ }
544
+ probing = false;
545
+ if (gaps.length < 20 || pinned !== "auto") return;
546
+ const slow = gaps.filter((gap) => gap > 26).length / gaps.length;
547
+ if (slow > 0.2) apply("low");
548
+ };
549
+ frame2 = requestAnimationFrame(step2);
550
+ void frame2;
551
+ }
552
+ function watchScroll() {
553
+ let timer = 0;
554
+ let probes = 0;
555
+ const settle = () => {
556
+ timer = 0;
557
+ root().removeAttribute("data-lg-scrolling");
558
+ };
559
+ const onScroll = () => {
560
+ if (!timer) {
561
+ root().setAttribute("data-lg-scrolling", "");
562
+ if (probes < 2) {
563
+ probes++;
564
+ probe();
565
+ }
566
+ } else {
567
+ clearTimeout(timer);
568
+ }
569
+ timer = window.setTimeout(settle, 140);
570
+ };
571
+ document.addEventListener("scroll", onScroll, { capture: true, passive: true });
572
+ }
573
+ function start() {
574
+ if (started || typeof window === "undefined") return;
575
+ started = true;
576
+ apply(pinned === "auto" ? guess() : pinned);
577
+ watchScroll();
578
+ if (typeof IntersectionObserver === "function") {
579
+ offscreen = new IntersectionObserver(
580
+ (entries) => {
581
+ for (const entry of entries) {
582
+ const el2 = entry.target;
583
+ if (entry.isIntersecting) el2.removeAttribute("data-lg-offscreen");
584
+ else el2.setAttribute("data-lg-offscreen", "");
585
+ }
586
+ },
587
+ // Turn back on a little before it scrolls into view.
588
+ { rootMargin: "25% 0px" }
589
+ );
590
+ }
591
+ }
592
+ function governRefraction(element) {
593
+ start();
594
+ offscreen?.observe(element);
595
+ return () => {
596
+ offscreen?.unobserve(element);
597
+ element.removeAttribute("data-lg-offscreen");
598
+ };
599
+ }
600
+ function setGlassQuality(quality) {
601
+ pinned = quality;
602
+ if (typeof window === "undefined") return;
603
+ if (!started) start();
604
+ apply(quality === "auto" ? guess() : quality);
605
+ }
606
+
515
607
  // src/engine/refraction.ts
516
608
  var SVG_NS = "http://www.w3.org/2000/svg";
517
609
  var cache = /* @__PURE__ */ new Map();
@@ -524,11 +616,11 @@ function el(name, attrs) {
524
616
  }
525
617
  function container() {
526
618
  if (defs?.isConnected) return defs;
527
- const root = el("svg", { width: 0, height: 0, "aria-hidden": "true", "data-liquid-glass-defs": "" });
528
- root.style.cssText = "position:absolute;width:0;height:0;overflow:hidden;pointer-events:none";
619
+ const root2 = el("svg", { width: 0, height: 0, "aria-hidden": "true", "data-liquid-glass-defs": "" });
620
+ root2.style.cssText = "position:absolute;width:0;height:0;overflow:hidden;pointer-events:none";
529
621
  defs = el("defs", {});
530
- root.append(defs);
531
- document.body.append(root);
622
+ root2.append(defs);
623
+ document.body.append(root2);
532
624
  return defs;
533
625
  }
534
626
  function canRefractBackdrop() {
@@ -587,6 +679,7 @@ function bake(width, height, radius, shape, pad = 0, simple = false, fringe = fa
587
679
  const t = clamp((Math.abs(py) - (edge - 2)) / 3, 0, 1);
588
680
  return 1 - t * t * (3 - 2 * t);
589
681
  };
682
+ const flat = simple && magnify ? Infinity : Math.max(shape.bezel * 1.7, 5);
590
683
  for (let y = 0; y < ch; y++) {
591
684
  for (let x = 0; x < cw; x++) {
592
685
  const px = (x + 0.5) * W / cw - W / 2;
@@ -597,6 +690,10 @@ function bake(width, height, radius, shape, pad = 0, simple = false, fringe = fa
597
690
  const oy = Math.max(qy, 0);
598
691
  const len = Math.hypot(ox, oy);
599
692
  const d = radius - (len + Math.min(Math.max(qx, qy), 0));
693
+ if (d > flat) {
694
+ inside[y * cw + x] = 1;
695
+ continue;
696
+ }
600
697
  let nx;
601
698
  let ny;
602
699
  if (len > 0) {
@@ -803,9 +900,12 @@ function bake(width, height, radius, shape, pad = 0, simple = false, fringe = fa
803
900
  );
804
901
  }
805
902
  let out = "bent";
903
+ const soften = shape.stretch > 0 ? 1.1 : 0.65;
806
904
  if (smooth) {
807
905
  filter.append(
808
- el("feGaussianBlur", { in: "bent", stdDeviation: box ? `${0.65 / W} ${0.65 / H}` : 0.65, result: "bent-soft" }),
906
+ // A stretched rim magnifies the pixel steps of whatever edge it smears,
907
+ // so it gets a little more softening.
908
+ el("feGaussianBlur", { in: "bent", stdDeviation: box ? `${soften / W} ${soften / H}` : soften, result: "bent-soft" }),
809
909
  el("feImage", { href: smooth, ...area, preserveAspectRatio: "none", result: "rim-zone" }),
810
910
  el("feComposite", { in: "bent-soft", in2: "rim-zone", operator: "in", result: "rim-soft" }),
811
911
  el("feComposite", { in: "bent", in2: "rim-zone", operator: "out", result: "core" }),
@@ -851,6 +951,34 @@ function glassFor(width, height, radius, shape = {}, pad = 0, simple = false, fr
851
951
  }
852
952
  return baked;
853
953
  }
954
+ var soon = [];
955
+ var later = [];
956
+ var pumping = false;
957
+ function pump() {
958
+ pumping = true;
959
+ const run = (deadline) => {
960
+ const end = performance.now() + 8;
961
+ const left = () => deadline ? deadline.timeRemaining() > 4 : performance.now() < end;
962
+ let ran = 0;
963
+ while ((soon.length || later.length) && (ran === 0 || left())) {
964
+ (soon.shift() ?? later.shift())();
965
+ ran++;
966
+ }
967
+ if (soon.length || later.length) idle(run);
968
+ else pumping = false;
969
+ };
970
+ idle(run);
971
+ }
972
+ function bakeSoon(job, urgent = true) {
973
+ (urgent ? soon : later).push(job);
974
+ if (!pumping) pump();
975
+ return () => {
976
+ for (const list of [soon, later]) {
977
+ const at = list.indexOf(job);
978
+ if (at >= 0) list.splice(at, 1);
979
+ }
980
+ };
981
+ }
854
982
  function idle(callback) {
855
983
  if (typeof requestIdleCallback === "function") {
856
984
  const handle2 = requestIdleCallback(callback, { timeout: 120 });
@@ -901,28 +1029,44 @@ function useRefraction(ref, shape = {}, enabled = true, mirror, mirrorActive) {
901
1029
  }
902
1030
  if (live || bendCopy && chromium) {
903
1031
  const backdrop = live ? baked.filter : glassFor(width, height, radius, { ...shape, zoom: 1, zoomX: 1, strength: (shape.strength ?? 1) * 0.45 }).filter;
904
- element.style.setProperty("--lg-filter", backdrop);
905
- element.setAttribute("data-lg-refract", "");
1032
+ element.style.setProperty("--lg-refraction", backdrop);
1033
+ element.setAttribute("data-lg-refract", shape.kind ?? "surface");
906
1034
  }
907
1035
  element.style.setProperty("--lg-rim", baked.rim);
908
1036
  };
1037
+ let seen = typeof IntersectionObserver !== "function";
1038
+ const request = () => {
1039
+ cancel?.();
1040
+ cancel = bakeSoon(fit, seen);
1041
+ };
1042
+ const near = typeof IntersectionObserver === "function" ? new IntersectionObserver(
1043
+ (entries) => {
1044
+ if (!entries.some((entry) => entry.isIntersecting)) return;
1045
+ seen = true;
1046
+ near?.disconnect();
1047
+ request();
1048
+ },
1049
+ { rootMargin: "100% 0px" }
1050
+ ) : null;
1051
+ near?.observe(element);
909
1052
  const observer = new ResizeObserver(() => {
910
1053
  cancel?.();
911
- const timer = setTimeout(() => {
912
- cancel = idle(fit);
913
- }, 140);
1054
+ const timer = setTimeout(request, 140);
914
1055
  cancel = () => clearTimeout(timer);
915
1056
  });
916
1057
  observer.observe(element);
917
- fit();
1058
+ request();
918
1059
  const source = mirror?.current;
919
1060
  const unmirror = !live && source ? mirrorBackdrop(element, source, () => pad, () => [zoomX, zoom], mirrorActive) : void 0;
920
1061
  applyCopyFilter();
1062
+ const ungovern = governRefraction(element);
921
1063
  return () => {
922
1064
  cancel?.();
923
1065
  unmirror?.();
1066
+ ungovern();
1067
+ near?.disconnect();
924
1068
  observer.disconnect();
925
- element.style.removeProperty("--lg-filter");
1069
+ element.style.removeProperty("--lg-refraction");
926
1070
  element.style.removeProperty("--lg-rim");
927
1071
  element.removeAttribute("data-lg-refract");
928
1072
  };
@@ -1557,6 +1701,7 @@ import { useRef as useRef7 } from "react";
1557
1701
 
1558
1702
  // src/engine/lensTrack.ts
1559
1703
  import { useEffect as useEffect5, useRef as useRef6 } from "react";
1704
+ var FOLLOW2 = springFrom(0.2, 0.82);
1560
1705
  function useLensTrack(refs, options) {
1561
1706
  const latest = useRef6(options);
1562
1707
  latest.current = options;
@@ -1567,13 +1712,15 @@ function useLensTrack(refs, options) {
1567
1712
  const glass = refs.glass.current;
1568
1713
  const select = refs.select.current;
1569
1714
  if (!bar || !lens || !glass || !select) return;
1715
+ const parent = bar.parentElement;
1716
+ const shell = parent?.classList.contains("lg-glass") && parent.childElementCount === 1 ? parent : bar;
1570
1717
  let slot = 0;
1571
1718
  let height = 0;
1572
1719
  let pad = 0;
1573
1720
  let padY = 0;
1574
1721
  let W = 0;
1575
1722
  let H = 0;
1576
- const state = { x: 0, lift: 0, swell: 0, squash: 0 };
1723
+ const state = { x: 0, lift: 0, swell: 0, squash: 0, pull: 0 };
1577
1724
  let current = latest.current.index;
1578
1725
  let gesture = null;
1579
1726
  let dropTimer = 0;
@@ -1628,11 +1775,14 @@ function useLensTrack(refs, options) {
1628
1775
  const kx = (slot + (W - slot) * lift2) / W * (1 + squash);
1629
1776
  const ky = (height + (H - height) * lift2) / H * (1 - squash * 0.6);
1630
1777
  const grow = 1 + latest.current.swell / Math.max(bar.offsetWidth, 1) * swell2;
1778
+ const pull2 = state.pull;
1779
+ const ey = Math.abs(pull2) / Math.max(bar.offsetHeight, 1);
1631
1780
  const transform = `translateX(${x2}px) scale(${kx}, ${ky})`;
1632
1781
  lens.style.transform = transform;
1633
1782
  select.style.transform = `translateX(${x2}px)`;
1634
1783
  lens.style.opacity = String(clamp(lift2 * 4, 0, 1));
1635
- bar.style.scale = `${grow}`;
1784
+ shell.style.scale = `${grow * (1 - ey * 0.15)} ${grow * (1 + ey * 0.5)}`;
1785
+ shell.style.translate = `0px ${pull2 / 2}px`;
1636
1786
  lens.style.setProperty("--lg-lift", String(clamp(lift2, 0, 1)));
1637
1787
  bar.style.setProperty("--lg-lift", String(clamp(lift2, 0, 1)));
1638
1788
  for (const glyph of glyphs) {
@@ -1702,6 +1852,18 @@ function useLensTrack(refs, options) {
1702
1852
  state.swell = value;
1703
1853
  paint();
1704
1854
  });
1855
+ const pullY = createSpring(0, SPRINGS.release, (value) => {
1856
+ state.pull = value;
1857
+ paint();
1858
+ });
1859
+ const pull = (dy) => {
1860
+ pullY.tune(FOLLOW2);
1861
+ pullY.set(rubberband(dy, Math.min(10, bar.offsetHeight * 0.2), 0.5));
1862
+ };
1863
+ const letGo = () => {
1864
+ pullY.tune(SPRINGS.release);
1865
+ pullY.set(0);
1866
+ };
1705
1867
  const place = (index, instant = false) => {
1706
1868
  current = index;
1707
1869
  if (!gesture) {
@@ -1734,7 +1896,7 @@ function useLensTrack(refs, options) {
1734
1896
  clearTimeout(dropTimer);
1735
1897
  measure();
1736
1898
  const box = bar.getBoundingClientRect();
1737
- gesture = { id: event.pointerId, startX: event.clientX, anchor: index * slot, moved: false, box, hovered: index, startedAt: performance.now() };
1899
+ gesture = { id: event.pointerId, startX: event.clientX, startY: event.clientY, anchor: index * slot, moved: false, box, hovered: index, startedAt: performance.now() };
1738
1900
  suppressClick = false;
1739
1901
  bar.dataset.lifted = "";
1740
1902
  preview(index);
@@ -1759,6 +1921,7 @@ function useLensTrack(refs, options) {
1759
1921
  }
1760
1922
  }
1761
1923
  light(event.clientX, gesture.box);
1924
+ pull(event.clientY - gesture.startY);
1762
1925
  if (!gesture.moved) return;
1763
1926
  const at = position(event.clientX);
1764
1927
  x.tune(SPRINGS.drag);
@@ -1789,6 +1952,7 @@ function useLensTrack(refs, options) {
1789
1952
  else drop();
1790
1953
  swell.tune(SPRINGS.release);
1791
1954
  swell.set(0);
1955
+ letGo();
1792
1956
  x.tune(SPRINGS.snap);
1793
1957
  if (commit && (moved || inside)) {
1794
1958
  suppressClick = true;
@@ -1817,6 +1981,7 @@ function useLensTrack(refs, options) {
1817
1981
  lift.set(0);
1818
1982
  swell.tune(SPRINGS.release);
1819
1983
  swell.set(0);
1984
+ letGo();
1820
1985
  x.tune(SPRINGS.snap);
1821
1986
  x.set(current * slot);
1822
1987
  };
@@ -1866,7 +2031,9 @@ function useLensTrack(refs, options) {
1866
2031
  return () => {
1867
2032
  clearTimeout(dropTimer);
1868
2033
  api.current = null;
1869
- [x, lift, swell, jelly].forEach((s) => s.stop());
2034
+ [x, lift, swell, pullY, jelly].forEach((s) => s.stop());
2035
+ shell.style.removeProperty("scale");
2036
+ shell.style.removeProperty("translate");
1870
2037
  unguard();
1871
2038
  observer.disconnect();
1872
2039
  bar.removeEventListener("pointerdown", onDown);
@@ -2065,7 +2232,7 @@ var GlassSlider = React9.forwardRef(
2065
2232
  useImperativeHandle4(forwardedRef, () => inputRef.current);
2066
2233
  useEffect6(() => {
2067
2234
  const input2 = inputRef.current;
2068
- const root = rootRef.current;
2235
+ const root2 = rootRef.current;
2069
2236
  const setValue = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value").set;
2070
2237
  let drag = null;
2071
2238
  const update = (clientX) => {
@@ -2079,7 +2246,7 @@ var GlassSlider = React9.forwardRef(
2079
2246
  next = clamp(min + Math.round((next - min) / increment) * increment, min, max);
2080
2247
  next = Number(next.toFixed(10));
2081
2248
  }
2082
- root.style.setProperty("--lg-progress", String((next - min) / (max - min)));
2249
+ root2.style.setProperty("--lg-progress", String((next - min) / (max - min)));
2083
2250
  if (next === input2.valueAsNumber) return;
2084
2251
  setValue.call(input2, String(next));
2085
2252
  input2.dispatchEvent(new Event("input", { bubbles: true }));
@@ -2087,15 +2254,15 @@ var GlassSlider = React9.forwardRef(
2087
2254
  const down = (event) => {
2088
2255
  if (input2.disabled || !event.isPrimary || event.button !== 0 || drag) return;
2089
2256
  event.preventDefault();
2090
- delete root.dataset.keyboard;
2257
+ delete root2.dataset.keyboard;
2091
2258
  if (event.pointerType !== "touch") input2.focus({ preventScroll: true });
2092
- const box = root.getBoundingClientRect();
2093
- const inset = showThumb ? 19 * box.width / root.offsetWidth : 0;
2259
+ const box = root2.getBoundingClientRect();
2260
+ const inset = showThumb ? 19 * box.width / root2.offsetWidth : 0;
2094
2261
  const from = max > min ? clamp((input2.valueAsNumber - min) / (max - min), 0, 1) : 0;
2095
2262
  drag = { id: event.pointerId, x: event.clientX, from, travel: Math.max(1, box.width - inset * 2) };
2096
2263
  pastRef.current = 0;
2097
- root.dataset.dragging = "";
2098
- root.setPointerCapture(event.pointerId);
2264
+ root2.dataset.dragging = "";
2265
+ root2.setPointerCapture(event.pointerId);
2099
2266
  };
2100
2267
  const move = (event) => {
2101
2268
  if (event.pointerId !== drag?.id) return;
@@ -2107,29 +2274,29 @@ var GlassSlider = React9.forwardRef(
2107
2274
  const id = drag.id;
2108
2275
  drag = null;
2109
2276
  pastRef.current = 0;
2110
- delete root.dataset.dragging;
2111
- if (root.hasPointerCapture(id)) root.releasePointerCapture(id);
2277
+ delete root2.dataset.dragging;
2278
+ if (root2.hasPointerCapture(id)) root2.releasePointerCapture(id);
2112
2279
  };
2113
2280
  const up = (event) => {
2114
2281
  if (event.pointerId !== drag?.id) return;
2115
2282
  update(event.clientX);
2116
2283
  release();
2117
2284
  };
2118
- const unguard = guardSelection(root);
2119
- root.addEventListener("pointerdown", down);
2120
- root.addEventListener("pointermove", move);
2121
- root.addEventListener("pointerup", up);
2122
- root.addEventListener("pointercancel", release);
2123
- root.addEventListener("lostpointercapture", release);
2285
+ const unguard = guardSelection(root2);
2286
+ root2.addEventListener("pointerdown", down);
2287
+ root2.addEventListener("pointermove", move);
2288
+ root2.addEventListener("pointerup", up);
2289
+ root2.addEventListener("pointercancel", release);
2290
+ root2.addEventListener("lostpointercapture", release);
2124
2291
  window.addEventListener("blur", release);
2125
2292
  return () => {
2126
2293
  release();
2127
2294
  unguard();
2128
- root.removeEventListener("pointerdown", down);
2129
- root.removeEventListener("pointermove", move);
2130
- root.removeEventListener("pointerup", up);
2131
- root.removeEventListener("pointercancel", release);
2132
- root.removeEventListener("lostpointercapture", release);
2295
+ root2.removeEventListener("pointerdown", down);
2296
+ root2.removeEventListener("pointermove", move);
2297
+ root2.removeEventListener("pointerup", up);
2298
+ root2.removeEventListener("pointercancel", release);
2299
+ root2.removeEventListener("lostpointercapture", release);
2133
2300
  window.removeEventListener("blur", release);
2134
2301
  };
2135
2302
  }, [min, max, step2, showThumb]);
@@ -2150,16 +2317,16 @@ var GlassSlider = React9.forwardRef(
2150
2317
  const input2 = inputRef.current;
2151
2318
  const thumb = thumbRef.current;
2152
2319
  const face = faceRef.current;
2153
- const root = rootRef.current;
2320
+ const root2 = rootRef.current;
2154
2321
  const v = { lift: 0, stretch: 0, over: 0 };
2155
2322
  const paint = () => {
2156
2323
  const s = 0.655 + 0.345 * v.lift;
2157
2324
  const pull = Math.abs(v.over) / 58 * 0.6;
2158
2325
  thumb.style.scale = `${s * (1 + v.stretch + pull)} ${s * (1 - v.stretch * 0.5 - pull * 0.4)}`;
2159
2326
  face.style.opacity = String(1 - clamp(v.lift, 0, 1) * 0.92);
2160
- root.style.setProperty("--lg-lift", String(clamp(v.lift, 0, 1)));
2161
- root.style.setProperty("--lg-over", `${v.over.toFixed(2)}px`);
2162
- if (v.lift < 0.01 && lift.target === 0) delete root.dataset.lifted;
2327
+ root2.style.setProperty("--lg-lift", String(clamp(v.lift, 0, 1)));
2328
+ root2.style.setProperty("--lg-over", `${v.over.toFixed(2)}px`);
2329
+ if (v.lift < 0.01 && lift.target === 0) delete root2.dataset.lifted;
2163
2330
  };
2164
2331
  const lift = createSpring(0, SPRINGS.lift, (x) => {
2165
2332
  v.lift = x;
@@ -2180,7 +2347,7 @@ var GlassSlider = React9.forwardRef(
2180
2347
  if (input2.disabled || !event.isPrimary || event.button !== 0) return;
2181
2348
  lastX = event.clientX;
2182
2349
  lastT = event.timeStamp;
2183
- root.dataset.lifted = "";
2350
+ root2.dataset.lifted = "";
2184
2351
  lift.tune(SPRINGS.lift);
2185
2352
  lift.set(1);
2186
2353
  haptic();
@@ -2205,30 +2372,30 @@ var GlassSlider = React9.forwardRef(
2205
2372
  over.tune(SPRINGS.release);
2206
2373
  over.set(0);
2207
2374
  };
2208
- root.addEventListener("pointerdown", down);
2375
+ root2.addEventListener("pointerdown", down);
2209
2376
  window.addEventListener("pointermove", move);
2210
2377
  window.addEventListener("pointerup", up);
2211
2378
  window.addEventListener("pointercancel", up);
2212
- root.addEventListener("lostpointercapture", up);
2379
+ root2.addEventListener("lostpointercapture", up);
2213
2380
  window.addEventListener("blur", up);
2214
2381
  return () => {
2215
2382
  lift.stop();
2216
2383
  stretch.stop();
2217
2384
  over.stop();
2218
- root.removeEventListener("pointerdown", down);
2385
+ root2.removeEventListener("pointerdown", down);
2219
2386
  window.removeEventListener("pointermove", move);
2220
2387
  window.removeEventListener("pointerup", up);
2221
2388
  window.removeEventListener("pointercancel", up);
2222
- root.removeEventListener("lostpointercapture", up);
2389
+ root2.removeEventListener("lostpointercapture", up);
2223
2390
  window.removeEventListener("blur", up);
2224
- delete root.dataset.lifted;
2391
+ delete root2.dataset.lifted;
2225
2392
  };
2226
2393
  }, [showThumb]);
2227
2394
  useEffect6(() => {
2228
2395
  if (showThumb) return;
2229
2396
  const input2 = inputRef.current;
2230
2397
  const block = blockRef.current;
2231
- const root = rootRef.current;
2398
+ const root2 = rootRef.current;
2232
2399
  const v = { swell: 0, over: 0 };
2233
2400
  const paint = () => {
2234
2401
  const w = block.offsetWidth || 1;
@@ -2269,8 +2436,8 @@ var GlassSlider = React9.forwardRef(
2269
2436
  const up = (event) => {
2270
2437
  if (event.pointerId === active2?.id) reset();
2271
2438
  };
2272
- root.addEventListener("pointerdown", down);
2273
- root.addEventListener("lostpointercapture", reset);
2439
+ root2.addEventListener("pointerdown", down);
2440
+ root2.addEventListener("lostpointercapture", reset);
2274
2441
  window.addEventListener("blur", reset);
2275
2442
  window.addEventListener("pointermove", move);
2276
2443
  window.addEventListener("pointerup", up);
@@ -2278,8 +2445,8 @@ var GlassSlider = React9.forwardRef(
2278
2445
  return () => {
2279
2446
  swell.stop();
2280
2447
  over.stop();
2281
- root.removeEventListener("pointerdown", down);
2282
- root.removeEventListener("lostpointercapture", reset);
2448
+ root2.removeEventListener("pointerdown", down);
2449
+ root2.removeEventListener("lostpointercapture", reset);
2283
2450
  window.removeEventListener("blur", reset);
2284
2451
  window.removeEventListener("pointermove", move);
2285
2452
  window.removeEventListener("pointerup", up);
@@ -2379,7 +2546,7 @@ var GlassSwitch = React10.forwardRef(
2379
2546
  const sync = useRef9(null);
2380
2547
  useRefraction(
2381
2548
  thumbRef,
2382
- { kind: "lens", zoom: 0.72, zoomX: 1, dispersion: 1, stretch: 1, copy: "refract", strength: Math.max(1, Math.min(10, intensity)) / 5 },
2549
+ { kind: "lens", zoom: 0.72, zoomX: 1, dispersion: 0, stretch: 1, copy: "refract", strength: Math.max(1, Math.min(10, intensity)) / 5 },
2383
2550
  true,
2384
2551
  ref,
2385
2552
  () => parseFloat(ref.current?.style.getPropertyValue("--lg-lift") || "0") > 0.01
@@ -2712,6 +2879,7 @@ export {
2712
2879
  canRefractBackdrop,
2713
2880
  createSpring,
2714
2881
  haptic,
2882
+ setGlassQuality,
2715
2883
  springFrom,
2716
2884
  useGlassAnimation,
2717
2885
  useGlassEffect,