@bwp-web/canvas 1.0.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/README.md +307 -0
- package/dist/hooks/useEditCanvas.d.ts +2 -2
- package/dist/hooks/useViewCanvas.d.ts +2 -2
- package/dist/index.cjs +199 -91
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +204 -92
- package/dist/index.js.map +1 -1
- package/dist/overlay/FixedSizeContent.d.ts.map +1 -1
- package/dist/overlay/ObjectOverlay.d.ts +4 -0
- package/dist/overlay/ObjectOverlay.d.ts.map +1 -1
- package/dist/overlay/OverlayBadge.d.ts +6 -6
- package/dist/overlay/OverlayBadge.d.ts.map +1 -1
- package/dist/overlay/OverlayContainer.d.ts +43 -0
- package/dist/overlay/OverlayContainer.d.ts.map +1 -0
- package/dist/overlay/OverlayContent.d.ts +2 -2
- package/dist/overlay/OverlayContent.d.ts.map +1 -1
- package/dist/overlay/index.d.ts +2 -0
- package/dist/overlay/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,8 @@ export type { ViewCanvasProviderProps, ViewCanvasContextValue, ViewCanvasViewpor
|
|
|
20
20
|
export { useCanvasRef } from './context';
|
|
21
21
|
export { ObjectOverlay } from './overlay';
|
|
22
22
|
export type { ObjectOverlayProps } from './overlay';
|
|
23
|
+
export { OverlayContainer } from './overlay';
|
|
24
|
+
export type { OverlayContainerProps } from './overlay';
|
|
23
25
|
export { OverlayContent } from './overlay';
|
|
24
26
|
export type { OverlayContentProps } from './overlay';
|
|
25
27
|
export { FixedSizeContent } from './overlay';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,sBAAsB,CAAC;AAG9B,OAAO,EA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D,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAGhE,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,eAAe,EACf,UAAU,EACV,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,yBAAyB,GAC1B,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACd,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,kBAAkB,EAClB,YAAY,EACZ,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,6BAA6B,EAC7B,uBAAuB,GACxB,MAAM,UAAU,CAAC;AAKlB,OAAO,EACL,MAAM,IAAI,YAAY,EACtB,YAAY,EACZ,WAAW,EACX,IAAI,EACJ,OAAO,EACP,KAAK,EACL,IAAI,GACL,MAAM,QAAQ,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3451,10 +3451,66 @@ function useViewCanvasState() {
|
|
|
3451
3451
|
}
|
|
3452
3452
|
|
|
3453
3453
|
// src/overlay/ObjectOverlay.tsx
|
|
3454
|
-
import { useEffect as
|
|
3455
|
-
import { Stack } from "@mui/material";
|
|
3454
|
+
import { useEffect as useEffect8, useRef as useRef8 } from "react";
|
|
3455
|
+
import { Stack as Stack2 } from "@mui/material";
|
|
3456
3456
|
import { util as util4 } from "fabric";
|
|
3457
|
+
|
|
3458
|
+
// src/overlay/OverlayContainer.tsx
|
|
3459
|
+
import {
|
|
3460
|
+
createContext as createContext4,
|
|
3461
|
+
useContext as useContext4,
|
|
3462
|
+
useEffect as useEffect7,
|
|
3463
|
+
useRef as useRef7
|
|
3464
|
+
} from "react";
|
|
3465
|
+
import { Stack } from "@mui/material";
|
|
3457
3466
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
3467
|
+
var OverlayContainerContext = createContext4(false);
|
|
3468
|
+
function useIsInsideOverlayContainer() {
|
|
3469
|
+
return useContext4(OverlayContainerContext);
|
|
3470
|
+
}
|
|
3471
|
+
function OverlayContainer({
|
|
3472
|
+
canvasRef: canvasRefProp,
|
|
3473
|
+
children
|
|
3474
|
+
}) {
|
|
3475
|
+
const contextCanvasRef = useCanvasRef();
|
|
3476
|
+
const canvasRef = canvasRefProp ?? contextCanvasRef;
|
|
3477
|
+
const containerRef = useRef7(null);
|
|
3478
|
+
useEffect7(() => {
|
|
3479
|
+
const canvas = canvasRef?.current;
|
|
3480
|
+
const el = containerRef.current;
|
|
3481
|
+
if (!canvas || !el) return;
|
|
3482
|
+
function updateContainer() {
|
|
3483
|
+
if (!canvas || !el) return;
|
|
3484
|
+
const vt = canvas.viewportTransform;
|
|
3485
|
+
if (!vt) return;
|
|
3486
|
+
el.style.transform = `translate(${vt[4]}px, ${vt[5]}px)`;
|
|
3487
|
+
}
|
|
3488
|
+
updateContainer();
|
|
3489
|
+
canvas.on("after:render", updateContainer);
|
|
3490
|
+
return () => {
|
|
3491
|
+
canvas.off("after:render", updateContainer);
|
|
3492
|
+
};
|
|
3493
|
+
}, [canvasRef]);
|
|
3494
|
+
return /* @__PURE__ */ jsx4(OverlayContainerContext.Provider, { value: true, children: /* @__PURE__ */ jsx4(
|
|
3495
|
+
Stack,
|
|
3496
|
+
{
|
|
3497
|
+
ref: containerRef,
|
|
3498
|
+
sx: {
|
|
3499
|
+
position: "absolute",
|
|
3500
|
+
left: 0,
|
|
3501
|
+
top: 0,
|
|
3502
|
+
width: "100%",
|
|
3503
|
+
height: "100%",
|
|
3504
|
+
pointerEvents: "none",
|
|
3505
|
+
willChange: "transform"
|
|
3506
|
+
},
|
|
3507
|
+
children
|
|
3508
|
+
}
|
|
3509
|
+
) });
|
|
3510
|
+
}
|
|
3511
|
+
|
|
3512
|
+
// src/overlay/ObjectOverlay.tsx
|
|
3513
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
3458
3514
|
function ObjectOverlay({
|
|
3459
3515
|
canvasRef: canvasRefProp,
|
|
3460
3516
|
object,
|
|
@@ -3464,8 +3520,10 @@ function ObjectOverlay({
|
|
|
3464
3520
|
}) {
|
|
3465
3521
|
const contextCanvasRef = useCanvasRef();
|
|
3466
3522
|
const canvasRef = canvasRefProp ?? contextCanvasRef;
|
|
3467
|
-
const
|
|
3468
|
-
|
|
3523
|
+
const insideContainer = useIsInsideOverlayContainer();
|
|
3524
|
+
const stackRef = useRef8(null);
|
|
3525
|
+
const prev = useRef8({ transform: "", w: "", h: "", z: "" });
|
|
3526
|
+
useEffect8(() => {
|
|
3469
3527
|
const canvas = canvasRef?.current;
|
|
3470
3528
|
if (!canvas || !object) return;
|
|
3471
3529
|
function update() {
|
|
@@ -3477,15 +3535,37 @@ function ObjectOverlay({
|
|
|
3477
3535
|
const center = object.getCenterPoint();
|
|
3478
3536
|
const actualWidth = (object.width ?? 0) * (object.scaleX ?? 1);
|
|
3479
3537
|
const actualHeight = (object.height ?? 0) * (object.scaleY ?? 1);
|
|
3480
|
-
const screenCoords = util4.transformPoint(center, vt);
|
|
3481
3538
|
const screenWidth = actualWidth * zoom;
|
|
3482
3539
|
const screenHeight = actualHeight * zoom;
|
|
3483
3540
|
const angle = object.angle ?? 0;
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3541
|
+
let tx;
|
|
3542
|
+
let ty;
|
|
3543
|
+
if (insideContainer) {
|
|
3544
|
+
tx = center.x * zoom - screenWidth / 2;
|
|
3545
|
+
ty = center.y * zoom - screenHeight / 2;
|
|
3546
|
+
} else {
|
|
3547
|
+
const screenCoords = util4.transformPoint(center, vt);
|
|
3548
|
+
tx = screenCoords.x - screenWidth / 2;
|
|
3549
|
+
ty = screenCoords.y - screenHeight / 2;
|
|
3550
|
+
}
|
|
3551
|
+
const transform = angle !== 0 ? `translate(${tx}px, ${ty}px) rotate(${angle}deg)` : `translate(${tx}px, ${ty}px)`;
|
|
3552
|
+
if (transform !== prev.current.transform) {
|
|
3553
|
+
el.style.transform = transform;
|
|
3554
|
+
prev.current.transform = transform;
|
|
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
|
+
}
|
|
3561
|
+
const w = `${screenWidth}px`;
|
|
3562
|
+
const h = `${screenHeight}px`;
|
|
3563
|
+
if (prev.current.w !== w || prev.current.h !== h) {
|
|
3564
|
+
el.style.width = w;
|
|
3565
|
+
el.style.height = h;
|
|
3566
|
+
prev.current.w = w;
|
|
3567
|
+
prev.current.h = h;
|
|
3568
|
+
}
|
|
3489
3569
|
}
|
|
3490
3570
|
update();
|
|
3491
3571
|
canvas.on("after:render", update);
|
|
@@ -3497,19 +3577,23 @@ function ObjectOverlay({
|
|
|
3497
3577
|
object.off("moving", update);
|
|
3498
3578
|
object.off("scaling", update);
|
|
3499
3579
|
object.off("rotating", update);
|
|
3580
|
+
prev.current = { transform: "", w: "", h: "", z: "" };
|
|
3500
3581
|
};
|
|
3501
|
-
}, [canvasRef, object]);
|
|
3582
|
+
}, [canvasRef, object, insideContainer]);
|
|
3502
3583
|
if (!object) return null;
|
|
3503
|
-
return /* @__PURE__ */
|
|
3504
|
-
|
|
3584
|
+
return /* @__PURE__ */ jsx5(
|
|
3585
|
+
Stack2,
|
|
3505
3586
|
{
|
|
3506
3587
|
ref: stackRef,
|
|
3507
3588
|
sx: {
|
|
3508
3589
|
position: "absolute",
|
|
3590
|
+
left: 0,
|
|
3591
|
+
top: 0,
|
|
3509
3592
|
pointerEvents: "none",
|
|
3510
3593
|
alignItems: "center",
|
|
3511
3594
|
justifyContent: "center",
|
|
3512
3595
|
zIndex: 1,
|
|
3596
|
+
willChange: "transform",
|
|
3513
3597
|
...sx
|
|
3514
3598
|
},
|
|
3515
3599
|
...rest,
|
|
@@ -3519,28 +3603,28 @@ function ObjectOverlay({
|
|
|
3519
3603
|
}
|
|
3520
3604
|
|
|
3521
3605
|
// src/overlay/OverlayContent.tsx
|
|
3522
|
-
import { Stack as
|
|
3523
|
-
import { useEffect as
|
|
3524
|
-
import { jsx as
|
|
3606
|
+
import { Stack as Stack3 } from "@mui/material";
|
|
3607
|
+
import { useEffect as useEffect9, useRef as useRef9 } from "react";
|
|
3608
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
3525
3609
|
function OverlayContent({
|
|
3526
3610
|
children,
|
|
3527
|
-
padding =
|
|
3611
|
+
padding = 6,
|
|
3528
3612
|
maxScale = 2,
|
|
3529
3613
|
sx,
|
|
3530
3614
|
...rest
|
|
3531
3615
|
}) {
|
|
3532
|
-
const outerRef =
|
|
3533
|
-
const innerRef =
|
|
3534
|
-
|
|
3616
|
+
const outerRef = useRef9(null);
|
|
3617
|
+
const innerRef = useRef9(null);
|
|
3618
|
+
useEffect9(() => {
|
|
3535
3619
|
const outer = outerRef.current;
|
|
3536
3620
|
const inner = innerRef.current;
|
|
3537
3621
|
if (!outer || !inner) return;
|
|
3622
|
+
let natW = 0;
|
|
3623
|
+
let natH = 0;
|
|
3538
3624
|
function fit() {
|
|
3539
3625
|
if (!outer || !inner) return;
|
|
3540
3626
|
const containerW = outer.clientWidth;
|
|
3541
3627
|
const containerH = outer.clientHeight;
|
|
3542
|
-
const natW = inner.scrollWidth;
|
|
3543
|
-
const natH = inner.scrollHeight;
|
|
3544
3628
|
if (natW === 0 || natH === 0 || containerW <= 0 || containerH <= 0) {
|
|
3545
3629
|
inner.style.transform = "";
|
|
3546
3630
|
inner.style.removeProperty("--overlay-scale");
|
|
@@ -3554,14 +3638,25 @@ function OverlayContent({
|
|
|
3554
3638
|
inner.style.transform = `scale(${scale})`;
|
|
3555
3639
|
inner.style.setProperty("--overlay-scale", String(scale));
|
|
3556
3640
|
}
|
|
3557
|
-
const observer = new ResizeObserver(
|
|
3641
|
+
const observer = new ResizeObserver((entries) => {
|
|
3642
|
+
for (const entry of entries) {
|
|
3643
|
+
if (entry.target === inner) {
|
|
3644
|
+
natW = inner.scrollWidth;
|
|
3645
|
+
natH = inner.scrollHeight;
|
|
3646
|
+
break;
|
|
3647
|
+
}
|
|
3648
|
+
}
|
|
3649
|
+
fit();
|
|
3650
|
+
});
|
|
3558
3651
|
observer.observe(outer);
|
|
3559
3652
|
observer.observe(inner);
|
|
3653
|
+
natW = inner.scrollWidth;
|
|
3654
|
+
natH = inner.scrollHeight;
|
|
3560
3655
|
fit();
|
|
3561
3656
|
return () => observer.disconnect();
|
|
3562
3657
|
}, [padding, maxScale]);
|
|
3563
|
-
return /* @__PURE__ */
|
|
3564
|
-
|
|
3658
|
+
return /* @__PURE__ */ jsx6(
|
|
3659
|
+
Stack3,
|
|
3565
3660
|
{
|
|
3566
3661
|
ref: outerRef,
|
|
3567
3662
|
sx: {
|
|
@@ -3573,8 +3668,8 @@ function OverlayContent({
|
|
|
3573
3668
|
...sx
|
|
3574
3669
|
},
|
|
3575
3670
|
...rest,
|
|
3576
|
-
children: /* @__PURE__ */
|
|
3577
|
-
|
|
3671
|
+
children: /* @__PURE__ */ jsx6(
|
|
3672
|
+
Stack3,
|
|
3578
3673
|
{
|
|
3579
3674
|
ref: innerRef,
|
|
3580
3675
|
sx: {
|
|
@@ -3591,9 +3686,9 @@ function OverlayContent({
|
|
|
3591
3686
|
}
|
|
3592
3687
|
|
|
3593
3688
|
// src/overlay/FixedSizeContent.tsx
|
|
3594
|
-
import { Stack as
|
|
3595
|
-
import { useEffect as
|
|
3596
|
-
import { jsx as
|
|
3689
|
+
import { Stack as Stack4 } from "@mui/material";
|
|
3690
|
+
import { useEffect as useEffect10, useRef as useRef10 } from "react";
|
|
3691
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
3597
3692
|
function FixedSizeContent({
|
|
3598
3693
|
children,
|
|
3599
3694
|
hideOnOverflow = true,
|
|
@@ -3601,9 +3696,9 @@ function FixedSizeContent({
|
|
|
3601
3696
|
sx,
|
|
3602
3697
|
...rest
|
|
3603
3698
|
}) {
|
|
3604
|
-
const ref =
|
|
3605
|
-
const totalContentHeightRef =
|
|
3606
|
-
|
|
3699
|
+
const ref = useRef10(null);
|
|
3700
|
+
const totalContentHeightRef = useRef10(0);
|
|
3701
|
+
useEffect10(() => {
|
|
3607
3702
|
const el = ref.current;
|
|
3608
3703
|
if (!el) return;
|
|
3609
3704
|
let clipAncestor = el.parentElement;
|
|
@@ -3614,34 +3709,45 @@ function FixedSizeContent({
|
|
|
3614
3709
|
if (!clipAncestor) return;
|
|
3615
3710
|
const ancestor = clipAncestor;
|
|
3616
3711
|
totalContentHeightRef.current = el.parentElement?.scrollHeight ?? 0;
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
}
|
|
3630
|
-
} else if (!fits && el.style.display !== "none") {
|
|
3712
|
+
let rafId = 0;
|
|
3713
|
+
function doCheck() {
|
|
3714
|
+
if (!el) return;
|
|
3715
|
+
const containerW = ancestor.clientWidth;
|
|
3716
|
+
const containerH = ancestor.clientHeight;
|
|
3717
|
+
el.style.maxWidth = `${Math.max(0, containerW - truncationPadding * 2)}px`;
|
|
3718
|
+
if (!hideOnOverflow) return;
|
|
3719
|
+
const fits = containerH >= totalContentHeightRef.current;
|
|
3720
|
+
if (fits && el.style.display === "none") {
|
|
3721
|
+
el.style.display = "";
|
|
3722
|
+
totalContentHeightRef.current = el.parentElement?.scrollHeight ?? 0;
|
|
3723
|
+
if (containerH < totalContentHeightRef.current) {
|
|
3631
3724
|
el.style.display = "none";
|
|
3632
3725
|
}
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3726
|
+
} else if (!fits && el.style.display !== "none") {
|
|
3727
|
+
el.style.display = "none";
|
|
3728
|
+
}
|
|
3729
|
+
if (el.style.display !== "none") {
|
|
3730
|
+
totalContentHeightRef.current = el.parentElement?.scrollHeight ?? 0;
|
|
3731
|
+
}
|
|
3637
3732
|
}
|
|
3638
|
-
|
|
3733
|
+
function scheduleCheck() {
|
|
3734
|
+
if (!rafId) {
|
|
3735
|
+
rafId = requestAnimationFrame(() => {
|
|
3736
|
+
rafId = 0;
|
|
3737
|
+
doCheck();
|
|
3738
|
+
});
|
|
3739
|
+
}
|
|
3740
|
+
}
|
|
3741
|
+
const observer = new ResizeObserver(scheduleCheck);
|
|
3639
3742
|
observer.observe(ancestor);
|
|
3640
|
-
|
|
3641
|
-
return () =>
|
|
3743
|
+
scheduleCheck();
|
|
3744
|
+
return () => {
|
|
3745
|
+
if (rafId) cancelAnimationFrame(rafId);
|
|
3746
|
+
observer.disconnect();
|
|
3747
|
+
};
|
|
3642
3748
|
}, [hideOnOverflow, truncationPadding]);
|
|
3643
|
-
return /* @__PURE__ */
|
|
3644
|
-
|
|
3749
|
+
return /* @__PURE__ */ jsx7(
|
|
3750
|
+
Stack4,
|
|
3645
3751
|
{
|
|
3646
3752
|
ref,
|
|
3647
3753
|
sx: {
|
|
@@ -3665,9 +3771,9 @@ function FixedSizeContent({
|
|
|
3665
3771
|
}
|
|
3666
3772
|
|
|
3667
3773
|
// src/overlay/OverlayBadge.tsx
|
|
3668
|
-
import { Stack as
|
|
3669
|
-
import { useEffect as
|
|
3670
|
-
import { jsx as
|
|
3774
|
+
import { Stack as Stack5 } from "@mui/material";
|
|
3775
|
+
import { useEffect as useEffect11, useRef as useRef11 } from "react";
|
|
3776
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
3671
3777
|
function toPx(v) {
|
|
3672
3778
|
if (v === void 0) return void 0;
|
|
3673
3779
|
return typeof v === "number" ? `${v}px` : v;
|
|
@@ -3697,10 +3803,19 @@ function ellipsePosition(angleDeg) {
|
|
|
3697
3803
|
function toNum(v) {
|
|
3698
3804
|
return typeof v === "number" ? v : 0;
|
|
3699
3805
|
}
|
|
3806
|
+
function readInlineProperty(el, prop) {
|
|
3807
|
+
let node = el.parentElement;
|
|
3808
|
+
while (node) {
|
|
3809
|
+
const val = node.style.getPropertyValue(prop);
|
|
3810
|
+
if (val) return parseFloat(val) || 1;
|
|
3811
|
+
node = node.parentElement;
|
|
3812
|
+
}
|
|
3813
|
+
return 1;
|
|
3814
|
+
}
|
|
3700
3815
|
function OverlayBadge({
|
|
3701
3816
|
children,
|
|
3702
|
-
maxScale =
|
|
3703
|
-
minScale = 0.
|
|
3817
|
+
maxScale = 1.5,
|
|
3818
|
+
minScale = 0.5,
|
|
3704
3819
|
top,
|
|
3705
3820
|
right,
|
|
3706
3821
|
bottom,
|
|
@@ -3709,43 +3824,39 @@ function OverlayBadge({
|
|
|
3709
3824
|
sx,
|
|
3710
3825
|
...rest
|
|
3711
3826
|
}) {
|
|
3712
|
-
const ref =
|
|
3713
|
-
|
|
3714
|
-
useEffect10(() => {
|
|
3827
|
+
const ref = useRef11(null);
|
|
3828
|
+
useEffect11(() => {
|
|
3715
3829
|
const el = ref.current;
|
|
3716
3830
|
if (!el) return;
|
|
3717
3831
|
const ancestor = el.parentElement;
|
|
3718
3832
|
if (!ancestor) return;
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
)
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
const scale = `scale(${ownScale / overlayScale})`;
|
|
3740
|
-
el.style.transform = circular ? `translate(-50%, -50%) ${scale}` : scale;
|
|
3741
|
-
});
|
|
3833
|
+
let rafId = 0;
|
|
3834
|
+
function doUpdate() {
|
|
3835
|
+
if (!el || !ancestor) return;
|
|
3836
|
+
if (ancestor.clientWidth <= 0 || ancestor.clientHeight <= 0) {
|
|
3837
|
+
el.style.transform = "";
|
|
3838
|
+
return;
|
|
3839
|
+
}
|
|
3840
|
+
const zoom = readInlineProperty(el, "--overlay-zoom");
|
|
3841
|
+
const ownScale = Math.max(minScale, Math.min(zoom, maxScale));
|
|
3842
|
+
const overlayScale = readInlineProperty(el, "--overlay-scale");
|
|
3843
|
+
const scale = `scale(${ownScale / overlayScale})`;
|
|
3844
|
+
el.style.transform = circular ? `translate(-50%, -50%) ${scale}` : scale;
|
|
3845
|
+
}
|
|
3846
|
+
function scheduleUpdate() {
|
|
3847
|
+
if (!rafId) {
|
|
3848
|
+
rafId = requestAnimationFrame(() => {
|
|
3849
|
+
rafId = 0;
|
|
3850
|
+
doUpdate();
|
|
3851
|
+
});
|
|
3852
|
+
}
|
|
3742
3853
|
}
|
|
3743
|
-
const observer = new ResizeObserver(
|
|
3854
|
+
const observer = new ResizeObserver(scheduleUpdate);
|
|
3744
3855
|
observer.observe(ancestor);
|
|
3745
|
-
|
|
3856
|
+
scheduleUpdate();
|
|
3746
3857
|
return () => {
|
|
3858
|
+
if (rafId) cancelAnimationFrame(rafId);
|
|
3747
3859
|
observer.disconnect();
|
|
3748
|
-
baseSize.current = null;
|
|
3749
3860
|
};
|
|
3750
3861
|
}, [maxScale, minScale, circular]);
|
|
3751
3862
|
const positionSx = circular ? (() => {
|
|
@@ -3763,8 +3874,8 @@ function OverlayBadge({
|
|
|
3763
3874
|
bottom: toPx(bottom),
|
|
3764
3875
|
left: toPx(left)
|
|
3765
3876
|
};
|
|
3766
|
-
return /* @__PURE__ */
|
|
3767
|
-
|
|
3877
|
+
return /* @__PURE__ */ jsx8(
|
|
3878
|
+
Stack5,
|
|
3768
3879
|
{
|
|
3769
3880
|
ref,
|
|
3770
3881
|
sx: {
|
|
@@ -3808,6 +3919,7 @@ export {
|
|
|
3808
3919
|
FixedSizeContent,
|
|
3809
3920
|
ObjectOverlay,
|
|
3810
3921
|
OverlayBadge,
|
|
3922
|
+
OverlayContainer,
|
|
3811
3923
|
OverlayContent,
|
|
3812
3924
|
Point9 as Point,
|
|
3813
3925
|
Polygon5 as Polygon,
|