@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.cjs
CHANGED
|
@@ -3595,7 +3595,7 @@ function ObjectOverlay({
|
|
|
3595
3595
|
const canvasRef = canvasRefProp ?? contextCanvasRef;
|
|
3596
3596
|
const insideContainer = useIsInsideOverlayContainer();
|
|
3597
3597
|
const stackRef = (0, import_react12.useRef)(null);
|
|
3598
|
-
const prev = (0, import_react12.useRef)({ transform: "", w: "", h: "" });
|
|
3598
|
+
const prev = (0, import_react12.useRef)({ transform: "", w: "", h: "", z: "" });
|
|
3599
3599
|
(0, import_react12.useEffect)(() => {
|
|
3600
3600
|
const canvas = canvasRef?.current;
|
|
3601
3601
|
if (!canvas || !object) return;
|
|
@@ -3626,6 +3626,11 @@ function ObjectOverlay({
|
|
|
3626
3626
|
el.style.transform = transform;
|
|
3627
3627
|
prev.current.transform = transform;
|
|
3628
3628
|
}
|
|
3629
|
+
const z = String(zoom);
|
|
3630
|
+
if (prev.current.z !== z) {
|
|
3631
|
+
el.style.setProperty("--overlay-zoom", z);
|
|
3632
|
+
prev.current.z = z;
|
|
3633
|
+
}
|
|
3629
3634
|
const w = `${screenWidth}px`;
|
|
3630
3635
|
const h = `${screenHeight}px`;
|
|
3631
3636
|
if (prev.current.w !== w || prev.current.h !== h) {
|
|
@@ -3645,7 +3650,7 @@ function ObjectOverlay({
|
|
|
3645
3650
|
object.off("moving", update);
|
|
3646
3651
|
object.off("scaling", update);
|
|
3647
3652
|
object.off("rotating", update);
|
|
3648
|
-
prev.current = { transform: "", w: "", h: "" };
|
|
3653
|
+
prev.current = { transform: "", w: "", h: "", z: "" };
|
|
3649
3654
|
};
|
|
3650
3655
|
}, [canvasRef, object, insideContainer]);
|
|
3651
3656
|
if (!object) return null;
|
|
@@ -3871,10 +3876,10 @@ function ellipsePosition(angleDeg) {
|
|
|
3871
3876
|
function toNum(v) {
|
|
3872
3877
|
return typeof v === "number" ? v : 0;
|
|
3873
3878
|
}
|
|
3874
|
-
function
|
|
3879
|
+
function readInlineProperty(el, prop) {
|
|
3875
3880
|
let node = el.parentElement;
|
|
3876
3881
|
while (node) {
|
|
3877
|
-
const val = node.style.getPropertyValue(
|
|
3882
|
+
const val = node.style.getPropertyValue(prop);
|
|
3878
3883
|
if (val) return parseFloat(val) || 1;
|
|
3879
3884
|
node = node.parentElement;
|
|
3880
3885
|
}
|
|
@@ -3893,7 +3898,6 @@ function OverlayBadge({
|
|
|
3893
3898
|
...rest
|
|
3894
3899
|
}) {
|
|
3895
3900
|
const ref = (0, import_react15.useRef)(null);
|
|
3896
|
-
const baseSize = (0, import_react15.useRef)(null);
|
|
3897
3901
|
(0, import_react15.useEffect)(() => {
|
|
3898
3902
|
const el = ref.current;
|
|
3899
3903
|
if (!el) return;
|
|
@@ -3902,21 +3906,13 @@ function OverlayBadge({
|
|
|
3902
3906
|
let rafId = 0;
|
|
3903
3907
|
function doUpdate() {
|
|
3904
3908
|
if (!el || !ancestor) return;
|
|
3905
|
-
|
|
3906
|
-
const containerH = ancestor.clientHeight;
|
|
3907
|
-
if (containerW <= 0 || containerH <= 0) {
|
|
3909
|
+
if (ancestor.clientWidth <= 0 || ancestor.clientHeight <= 0) {
|
|
3908
3910
|
el.style.transform = "";
|
|
3909
3911
|
return;
|
|
3910
3912
|
}
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
const ratio = Math.min(
|
|
3915
|
-
containerW / baseSize.current.w,
|
|
3916
|
-
containerH / baseSize.current.h
|
|
3917
|
-
);
|
|
3918
|
-
const ownScale = Math.max(minScale, Math.min(ratio, maxScale));
|
|
3919
|
-
const overlayScale = readOverlayScale(el);
|
|
3913
|
+
const zoom = readInlineProperty(el, "--overlay-zoom");
|
|
3914
|
+
const ownScale = Math.max(minScale, Math.min(zoom, maxScale));
|
|
3915
|
+
const overlayScale = readInlineProperty(el, "--overlay-scale");
|
|
3920
3916
|
const scale = `scale(${ownScale / overlayScale})`;
|
|
3921
3917
|
el.style.transform = circular ? `translate(-50%, -50%) ${scale}` : scale;
|
|
3922
3918
|
}
|
|
@@ -3934,7 +3930,6 @@ function OverlayBadge({
|
|
|
3934
3930
|
return () => {
|
|
3935
3931
|
if (rafId) cancelAnimationFrame(rafId);
|
|
3936
3932
|
observer.disconnect();
|
|
3937
|
-
baseSize.current = null;
|
|
3938
3933
|
};
|
|
3939
3934
|
}, [maxScale, minScale, circular]);
|
|
3940
3935
|
const positionSx = circular ? (() => {
|