@widgetic/canvas 0.5.15 → 0.5.16
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.
|
@@ -7946,13 +7946,26 @@ function checkAndAddNewShapeToFrame(shape: any) {
|
|
|
7946
7946
|
*/
|
|
7947
7947
|
function lockWidgetShapeBodyDrag(obj: any): void {
|
|
7948
7948
|
if (!obj?._isWidgetImage) return;
|
|
7949
|
+
// A live iframe owns the body so the page inside stays clickable.
|
|
7950
|
+
// Without that iframe the shape is an ordinary object and must move.
|
|
7951
|
+
const locked = obj._allowBodyDrag !== true;
|
|
7949
7952
|
obj.set({
|
|
7950
|
-
lockMovementX:
|
|
7951
|
-
lockMovementY:
|
|
7953
|
+
lockMovementX: locked,
|
|
7954
|
+
lockMovementY: locked,
|
|
7952
7955
|
});
|
|
7953
7956
|
obj.dirty = true;
|
|
7954
7957
|
}
|
|
7955
7958
|
|
|
7959
|
+
/** Live overlay present → body stays put. No overlay → the user can drag the shape. */
|
|
7960
|
+
export function setWidgetShapeBodyDragAllowed(widgetId: string, allowed: boolean): void {
|
|
7961
|
+
if (!canvas || !widgetId) return;
|
|
7962
|
+
const obj = canvas.getObjects().find((o: any) => o._isWidgetImage && o._widgetId === widgetId) as any;
|
|
7963
|
+
if (!obj || obj._allowBodyDrag === allowed) return;
|
|
7964
|
+
obj._allowBodyDrag = allowed;
|
|
7965
|
+
lockWidgetShapeBodyDrag(obj);
|
|
7966
|
+
canvas.requestRenderAll();
|
|
7967
|
+
}
|
|
7968
|
+
|
|
7956
7969
|
/** Translate a WidgetShape by screen-pixel delta (accounts for canvas zoom). */
|
|
7957
7970
|
export function translateWidgetShapeByScreen(widgetId: string, dxScreen: number, dyScreen: number): boolean {
|
|
7958
7971
|
if (!canvas || !widgetId) return false;
|
|
@@ -109,6 +109,7 @@ declare const __propDef: {
|
|
|
109
109
|
onSelectFrameTool?: () => void;
|
|
110
110
|
setPrimaryWidgetShape?: (widgetId: string) => boolean;
|
|
111
111
|
getPrimaryWidgetId?: () => string | null;
|
|
112
|
+
setWidgetShapeBodyDragAllowed?: (widgetId: string, allowed: boolean) => void;
|
|
112
113
|
translateWidgetShapeByScreen?: (widgetId: string, dxScreen: number, dyScreen: number) => boolean;
|
|
113
114
|
commitWidgetShapeTranslate?: (widgetId?: string | null) => void;
|
|
114
115
|
setWidgetShapeOverlayDragActive?: (active: boolean) => void;
|
|
@@ -211,6 +212,7 @@ export default class Canvas extends SvelteComponentTyped<CanvasProps, CanvasEven
|
|
|
211
212
|
get onSelectFrameTool(): () => void;
|
|
212
213
|
get setPrimaryWidgetShape(): (widgetId: string) => boolean;
|
|
213
214
|
get getPrimaryWidgetId(): () => string | null;
|
|
215
|
+
get setWidgetShapeBodyDragAllowed(): (widgetId: string, allowed: boolean) => void;
|
|
214
216
|
get translateWidgetShapeByScreen(): (widgetId: string, dxScreen: number, dyScreen: number) => boolean;
|
|
215
217
|
get commitWidgetShapeTranslate(): (widgetId?: string | null) => void;
|
|
216
218
|
get setWidgetShapeOverlayDragActive(): (active: boolean) => void;
|