@bwp-web/canvas 1.1.0 → 1.1.1
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
|
@@ -3522,7 +3522,7 @@ function ObjectOverlay({
|
|
|
3522
3522
|
const canvasRef = canvasRefProp ?? contextCanvasRef;
|
|
3523
3523
|
const insideContainer = useIsInsideOverlayContainer();
|
|
3524
3524
|
const stackRef = useRef8(null);
|
|
3525
|
-
const prev = useRef8({ transform: "", w: "", h: "" });
|
|
3525
|
+
const prev = useRef8({ transform: "", w: "", h: "", z: "" });
|
|
3526
3526
|
useEffect8(() => {
|
|
3527
3527
|
const canvas = canvasRef?.current;
|
|
3528
3528
|
if (!canvas || !object) return;
|
|
@@ -3553,6 +3553,11 @@ function ObjectOverlay({
|
|
|
3553
3553
|
el.style.transform = transform;
|
|
3554
3554
|
prev.current.transform = transform;
|
|
3555
3555
|
}
|
|
3556
|
+
const z = String(zoom);
|
|
3557
|
+
if (prev.current.z !== z) {
|
|
3558
|
+
el.style.setProperty("--overlay-zoom", z);
|
|
3559
|
+
prev.current.z = z;
|
|
3560
|
+
}
|
|
3556
3561
|
const w = `${screenWidth}px`;
|
|
3557
3562
|
const h = `${screenHeight}px`;
|
|
3558
3563
|
if (prev.current.w !== w || prev.current.h !== h) {
|
|
@@ -3572,7 +3577,7 @@ function ObjectOverlay({
|
|
|
3572
3577
|
object.off("moving", update);
|
|
3573
3578
|
object.off("scaling", update);
|
|
3574
3579
|
object.off("rotating", update);
|
|
3575
|
-
prev.current = { transform: "", w: "", h: "" };
|
|
3580
|
+
prev.current = { transform: "", w: "", h: "", z: "" };
|
|
3576
3581
|
};
|
|
3577
3582
|
}, [canvasRef, object, insideContainer]);
|
|
3578
3583
|
if (!object) return null;
|
|
@@ -3798,10 +3803,10 @@ function ellipsePosition(angleDeg) {
|
|
|
3798
3803
|
function toNum(v) {
|
|
3799
3804
|
return typeof v === "number" ? v : 0;
|
|
3800
3805
|
}
|
|
3801
|
-
function
|
|
3806
|
+
function readInlineProperty(el, prop) {
|
|
3802
3807
|
let node = el.parentElement;
|
|
3803
3808
|
while (node) {
|
|
3804
|
-
const val = node.style.getPropertyValue(
|
|
3809
|
+
const val = node.style.getPropertyValue(prop);
|
|
3805
3810
|
if (val) return parseFloat(val) || 1;
|
|
3806
3811
|
node = node.parentElement;
|
|
3807
3812
|
}
|
|
@@ -3820,7 +3825,6 @@ function OverlayBadge({
|
|
|
3820
3825
|
...rest
|
|
3821
3826
|
}) {
|
|
3822
3827
|
const ref = useRef11(null);
|
|
3823
|
-
const baseSize = useRef11(null);
|
|
3824
3828
|
useEffect11(() => {
|
|
3825
3829
|
const el = ref.current;
|
|
3826
3830
|
if (!el) return;
|
|
@@ -3829,21 +3833,13 @@ function OverlayBadge({
|
|
|
3829
3833
|
let rafId = 0;
|
|
3830
3834
|
function doUpdate() {
|
|
3831
3835
|
if (!el || !ancestor) return;
|
|
3832
|
-
|
|
3833
|
-
const containerH = ancestor.clientHeight;
|
|
3834
|
-
if (containerW <= 0 || containerH <= 0) {
|
|
3836
|
+
if (ancestor.clientWidth <= 0 || ancestor.clientHeight <= 0) {
|
|
3835
3837
|
el.style.transform = "";
|
|
3836
3838
|
return;
|
|
3837
3839
|
}
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
const ratio = Math.min(
|
|
3842
|
-
containerW / baseSize.current.w,
|
|
3843
|
-
containerH / baseSize.current.h
|
|
3844
|
-
);
|
|
3845
|
-
const ownScale = Math.max(minScale, Math.min(ratio, maxScale));
|
|
3846
|
-
const overlayScale = readOverlayScale(el);
|
|
3840
|
+
const zoom = readInlineProperty(el, "--overlay-zoom");
|
|
3841
|
+
const ownScale = Math.max(minScale, Math.min(zoom, maxScale));
|
|
3842
|
+
const overlayScale = readInlineProperty(el, "--overlay-scale");
|
|
3847
3843
|
const scale = `scale(${ownScale / overlayScale})`;
|
|
3848
3844
|
el.style.transform = circular ? `translate(-50%, -50%) ${scale}` : scale;
|
|
3849
3845
|
}
|
|
@@ -3861,7 +3857,6 @@ function OverlayBadge({
|
|
|
3861
3857
|
return () => {
|
|
3862
3858
|
if (rafId) cancelAnimationFrame(rafId);
|
|
3863
3859
|
observer.disconnect();
|
|
3864
|
-
baseSize.current = null;
|
|
3865
3860
|
};
|
|
3866
3861
|
}, [maxScale, minScale, circular]);
|
|
3867
3862
|
const positionSx = circular ? (() => {
|