@zakisheriff/liquid-glass 0.3.2 → 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/README.md +1 -1
- package/dist/index.js +22 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<br />
|
|
7
7
|
|
|
8
8
|
[](https://www.npmjs.com/package/@zakisheriff/liquid-glass)
|
|
9
|
-
[](https://www.npmjs.com/package/@zakisheriff/liquid-glass)
|
|
10
10
|
[](https://bundlephobia.com/package/@zakisheriff/liquid-glass)
|
|
11
11
|
[](https://www.npmjs.com/package/@zakisheriff/liquid-glass?activeTab=dependencies)
|
|
12
12
|
<br />
|
package/dist/index.js
CHANGED
|
@@ -358,6 +358,21 @@ function backdropChain(glass, source) {
|
|
|
358
358
|
}
|
|
359
359
|
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(" ");
|
|
360
360
|
var BACKGROUND = ["background-color", "background-image", "background-size", "background-position", "background-repeat", "border-radius"];
|
|
361
|
+
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"]);
|
|
362
|
+
function syncStyle(original, copy, root) {
|
|
363
|
+
for (const name of Array.from(copy.style)) {
|
|
364
|
+
if (root && PLACEMENT.has(name)) continue;
|
|
365
|
+
if (!original.style.getPropertyValue(name)) copy.style.removeProperty(name);
|
|
366
|
+
}
|
|
367
|
+
for (const name of Array.from(original.style)) {
|
|
368
|
+
if (root && PLACEMENT.has(name)) continue;
|
|
369
|
+
const value = original.style.getPropertyValue(name);
|
|
370
|
+
const priority = original.style.getPropertyPriority(name);
|
|
371
|
+
if (copy.style.getPropertyValue(name) !== value || copy.style.getPropertyPriority(name) !== priority) {
|
|
372
|
+
copy.style.setProperty(name, value, priority);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
361
376
|
function mirrorBackdrop(glass, source, padding, zoom, active2 = () => true) {
|
|
362
377
|
const layer = document.createElement("div");
|
|
363
378
|
layer.className = "lg-mirror";
|
|
@@ -455,11 +470,7 @@ function mirrorBackdrop(glass, source, padding, zoom, active2 = () => true) {
|
|
|
455
470
|
const cls = pair.original.className.toString();
|
|
456
471
|
if (css !== pair.css) {
|
|
457
472
|
pair.css = css;
|
|
458
|
-
|
|
459
|
-
else {
|
|
460
|
-
pair.copy.style.cssText = css;
|
|
461
|
-
placed = "";
|
|
462
|
-
}
|
|
473
|
+
syncStyle(pair.original, pair.copy, pair.copy === copy.root);
|
|
463
474
|
}
|
|
464
475
|
if (cls !== pair.cls) {
|
|
465
476
|
pair.cls = cls;
|
|
@@ -513,8 +524,13 @@ function mirrorBackdrop(glass, source, padding, zoom, active2 = () => true) {
|
|
|
513
524
|
if (records.every((r) => layer.contains(r.target) || r.target === layer || r.target === glass)) return;
|
|
514
525
|
const structural = records.some((r) => r.type !== "attributes" && !layer.contains(r.target));
|
|
515
526
|
if (structural && !pending) pending = requestAnimationFrame(recopy);
|
|
527
|
+
else if (!structural && !stopped && visible && !document.hidden && active2()) {
|
|
528
|
+
applyZoom();
|
|
529
|
+
sync();
|
|
530
|
+
align();
|
|
531
|
+
}
|
|
516
532
|
});
|
|
517
|
-
mutations.observe(source, { childList: true, characterData: true, subtree: true });
|
|
533
|
+
mutations.observe(source, { childList: true, characterData: true, attributes: true, attributeFilter: ["style", "class"], subtree: true });
|
|
518
534
|
const io = typeof IntersectionObserver === "function" ? new IntersectionObserver((entries) => {
|
|
519
535
|
visible = entries.some((e) => e.isIntersecting);
|
|
520
536
|
}) : null;
|