@bwp-web/canvas 1.1.0 → 1.1.2
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/hooks/useEditCanvas.d.ts.map +1 -1
- package/dist/index.cjs +19 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +19 -21
- package/dist/index.js.map +1 -1
- package/dist/overlay/ObjectOverlay.d.ts.map +1 -1
- package/dist/overlay/OverlayBadge.d.ts +4 -4
- package/dist/overlay/OverlayBadge.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEditCanvas.d.ts","sourceRoot":"","sources":["../../src/hooks/useEditCanvas.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,KAAK,YAAY,EAAW,MAAM,QAAQ,CAAC;AAC5E,OAAO,EAEL,KAAK,iBAAiB,EAEtB,KAAK,YAAY,EAClB,MAAM,aAAa,CAAC;AAMrB,OAAO,EAEL,KAAK,sBAAsB,EAE3B,KAAK,mBAAmB,EACzB,MAAM,cAAc,CAAC;AACtB,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,iBAAiB,CAAC;AAQzB,OAAO,EAIL,KAAK,kBAAkB,EAExB,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,KAAK,cAAc,EAEpB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtD,MAAM,WAAW,oBAAoB;IACnC,kGAAkG;IAClG,UAAU,CAAC,EAAE,OAAO,GAAG,iBAAiB,CAAC;IACzC,mIAAmI;IACnI,SAAS,CAAC,EAAE,OAAO,GAAG,sBAAsB,CAAC;IAC7C;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,GAAG,mBAAmB,CAAC;IAC7C;;;;;OAKG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IAC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CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,oBAAoB;IAsYtD,8CAA8C;sBApTvC,YAAY;IAsTnB,oDAAoD;;IAEpD,qCAAqC;;IAErC,mIAAmI;;IAEnI,qDAAqD;;IAErD,6CAA6C;;IAE7C,yBAAyB;;QAtFzB,wCAAwC;;QAExC,wDAAwD;wBAbjB,YAAY;QAenD,wFAAwF;;QAExF,2DAA2D;;QAE3D,0DAA0D;;QAE1D,uDAAuD;;QAEvD,6DAA6D;;;IA4E7D,+DAA+D;;IAE/D;;;;;;;;;;;;;;OAcG;qBA3X6B,SAAS,GAAG,IAAI;IA6XhD;;;;;;;OAOG;yBAnEO,MAAM,WAAW;QAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAAE;IAqEzD,uIAAuI;;IAEvI,4DAA4D;;IAE5D,oGAAoG;;IAEpG,sDAAsD;;IAEtD,iEAAiE;;IAEjE,mFAAmF;;IAEnF,kFAAkF;;IAElF,gFAAgF;;IAEhF,wEAAwE;8BAtJ/B,OAAO;EAwKrD"}
|
package/dist/index.cjs
CHANGED
|
@@ -2834,14 +2834,17 @@ function useEditCanvas(options) {
|
|
|
2834
2834
|
});
|
|
2835
2835
|
setObjects(loaded);
|
|
2836
2836
|
} finally {
|
|
2837
|
-
isInitialLoadRef.current = false;
|
|
2838
2837
|
setIsLoading(false);
|
|
2839
2838
|
}
|
|
2840
2839
|
}
|
|
2841
2840
|
})();
|
|
2842
2841
|
initPromise.then(async () => {
|
|
2843
|
-
|
|
2844
|
-
|
|
2842
|
+
try {
|
|
2843
|
+
const onReadyResult = opts?.onReady?.(canvas);
|
|
2844
|
+
await Promise.resolve(onReadyResult);
|
|
2845
|
+
} finally {
|
|
2846
|
+
isInitialLoadRef.current = false;
|
|
2847
|
+
}
|
|
2845
2848
|
if (opts?.invertBackground !== void 0) {
|
|
2846
2849
|
setBackgroundInverted(canvas, opts.invertBackground);
|
|
2847
2850
|
}
|
|
@@ -3595,7 +3598,7 @@ function ObjectOverlay({
|
|
|
3595
3598
|
const canvasRef = canvasRefProp ?? contextCanvasRef;
|
|
3596
3599
|
const insideContainer = useIsInsideOverlayContainer();
|
|
3597
3600
|
const stackRef = (0, import_react12.useRef)(null);
|
|
3598
|
-
const prev = (0, import_react12.useRef)({ transform: "", w: "", h: "" });
|
|
3601
|
+
const prev = (0, import_react12.useRef)({ transform: "", w: "", h: "", z: "" });
|
|
3599
3602
|
(0, import_react12.useEffect)(() => {
|
|
3600
3603
|
const canvas = canvasRef?.current;
|
|
3601
3604
|
if (!canvas || !object) return;
|
|
@@ -3626,6 +3629,11 @@ function ObjectOverlay({
|
|
|
3626
3629
|
el.style.transform = transform;
|
|
3627
3630
|
prev.current.transform = transform;
|
|
3628
3631
|
}
|
|
3632
|
+
const z = String(zoom);
|
|
3633
|
+
if (prev.current.z !== z) {
|
|
3634
|
+
el.style.setProperty("--overlay-zoom", z);
|
|
3635
|
+
prev.current.z = z;
|
|
3636
|
+
}
|
|
3629
3637
|
const w = `${screenWidth}px`;
|
|
3630
3638
|
const h = `${screenHeight}px`;
|
|
3631
3639
|
if (prev.current.w !== w || prev.current.h !== h) {
|
|
@@ -3645,7 +3653,7 @@ function ObjectOverlay({
|
|
|
3645
3653
|
object.off("moving", update);
|
|
3646
3654
|
object.off("scaling", update);
|
|
3647
3655
|
object.off("rotating", update);
|
|
3648
|
-
prev.current = { transform: "", w: "", h: "" };
|
|
3656
|
+
prev.current = { transform: "", w: "", h: "", z: "" };
|
|
3649
3657
|
};
|
|
3650
3658
|
}, [canvasRef, object, insideContainer]);
|
|
3651
3659
|
if (!object) return null;
|
|
@@ -3871,10 +3879,10 @@ function ellipsePosition(angleDeg) {
|
|
|
3871
3879
|
function toNum(v) {
|
|
3872
3880
|
return typeof v === "number" ? v : 0;
|
|
3873
3881
|
}
|
|
3874
|
-
function
|
|
3882
|
+
function readInlineProperty(el, prop) {
|
|
3875
3883
|
let node = el.parentElement;
|
|
3876
3884
|
while (node) {
|
|
3877
|
-
const val = node.style.getPropertyValue(
|
|
3885
|
+
const val = node.style.getPropertyValue(prop);
|
|
3878
3886
|
if (val) return parseFloat(val) || 1;
|
|
3879
3887
|
node = node.parentElement;
|
|
3880
3888
|
}
|
|
@@ -3893,7 +3901,6 @@ function OverlayBadge({
|
|
|
3893
3901
|
...rest
|
|
3894
3902
|
}) {
|
|
3895
3903
|
const ref = (0, import_react15.useRef)(null);
|
|
3896
|
-
const baseSize = (0, import_react15.useRef)(null);
|
|
3897
3904
|
(0, import_react15.useEffect)(() => {
|
|
3898
3905
|
const el = ref.current;
|
|
3899
3906
|
if (!el) return;
|
|
@@ -3902,21 +3909,13 @@ function OverlayBadge({
|
|
|
3902
3909
|
let rafId = 0;
|
|
3903
3910
|
function doUpdate() {
|
|
3904
3911
|
if (!el || !ancestor) return;
|
|
3905
|
-
|
|
3906
|
-
const containerH = ancestor.clientHeight;
|
|
3907
|
-
if (containerW <= 0 || containerH <= 0) {
|
|
3912
|
+
if (ancestor.clientWidth <= 0 || ancestor.clientHeight <= 0) {
|
|
3908
3913
|
el.style.transform = "";
|
|
3909
3914
|
return;
|
|
3910
3915
|
}
|
|
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);
|
|
3916
|
+
const zoom = readInlineProperty(el, "--overlay-zoom");
|
|
3917
|
+
const ownScale = Math.max(minScale, Math.min(zoom, maxScale));
|
|
3918
|
+
const overlayScale = readInlineProperty(el, "--overlay-scale");
|
|
3920
3919
|
const scale = `scale(${ownScale / overlayScale})`;
|
|
3921
3920
|
el.style.transform = circular ? `translate(-50%, -50%) ${scale}` : scale;
|
|
3922
3921
|
}
|
|
@@ -3934,7 +3933,6 @@ function OverlayBadge({
|
|
|
3934
3933
|
return () => {
|
|
3935
3934
|
if (rafId) cancelAnimationFrame(rafId);
|
|
3936
3935
|
observer.disconnect();
|
|
3937
|
-
baseSize.current = null;
|
|
3938
3936
|
};
|
|
3939
3937
|
}, [maxScale, minScale, circular]);
|
|
3940
3938
|
const positionSx = circular ? (() => {
|