@zakisheriff/liquid-glass 0.3.1 → 0.3.3

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
@@ -305,6 +305,21 @@ function backdropChain(glass, source) {
305
305
  }
306
306
  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(" ");
307
307
  var BACKGROUND = ["background-color", "background-image", "background-size", "background-position", "background-repeat", "border-radius"];
308
+ 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"]);
309
+ function syncStyle(original, copy, root) {
310
+ for (const name of Array.from(copy.style)) {
311
+ if (root && PLACEMENT.has(name)) continue;
312
+ if (!original.style.getPropertyValue(name)) copy.style.removeProperty(name);
313
+ }
314
+ for (const name of Array.from(original.style)) {
315
+ if (root && PLACEMENT.has(name)) continue;
316
+ const value = original.style.getPropertyValue(name);
317
+ const priority = original.style.getPropertyPriority(name);
318
+ if (copy.style.getPropertyValue(name) !== value || copy.style.getPropertyPriority(name) !== priority) {
319
+ copy.style.setProperty(name, value, priority);
320
+ }
321
+ }
322
+ }
308
323
  function mirrorBackdrop(glass, source, padding, zoom, active2 = () => true) {
309
324
  const layer = document.createElement("div");
310
325
  layer.className = "lg-mirror";
@@ -402,11 +417,7 @@ function mirrorBackdrop(glass, source, padding, zoom, active2 = () => true) {
402
417
  const cls = pair.original.className.toString();
403
418
  if (css !== pair.css) {
404
419
  pair.css = css;
405
- if (pair.copy !== copy.root) pair.copy.style.cssText = css;
406
- else {
407
- pair.copy.style.cssText = css;
408
- placed = "";
409
- }
420
+ syncStyle(pair.original, pair.copy, pair.copy === copy.root);
410
421
  }
411
422
  if (cls !== pair.cls) {
412
423
  pair.cls = cls;
@@ -460,8 +471,13 @@ function mirrorBackdrop(glass, source, padding, zoom, active2 = () => true) {
460
471
  if (records.every((r) => layer.contains(r.target) || r.target === layer || r.target === glass)) return;
461
472
  const structural = records.some((r) => r.type !== "attributes" && !layer.contains(r.target));
462
473
  if (structural && !pending) pending = requestAnimationFrame(recopy);
474
+ else if (!structural && !stopped && visible && !document.hidden && active2()) {
475
+ applyZoom();
476
+ sync();
477
+ align();
478
+ }
463
479
  });
464
- mutations.observe(source, { childList: true, characterData: true, subtree: true });
480
+ mutations.observe(source, { childList: true, characterData: true, attributes: true, attributeFilter: ["style", "class"], subtree: true });
465
481
  const io = typeof IntersectionObserver === "function" ? new IntersectionObserver((entries) => {
466
482
  visible = entries.some((e) => e.isIntersecting);
467
483
  }) : null;