feat: add dragMode option to ResizerOptions interface for flexible resizing behavior

This commit is contained in:
Luís Landeiro Ribeiro
2025-04-15 13:59:30 +01:00
parent b4b47f4d55
commit 15091f7fad
5 changed files with 18 additions and 5 deletions

2
dist/grapes.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

13
dist/grapes.mjs vendored
View File

@@ -53696,6 +53696,11 @@ var Resizer = /** @class */ (function () {
var parentEl = this.getParentEl(); var parentEl = this.getParentEl();
var resizer = this; var resizer = this;
var config = this.opts || {}; var config = this.opts || {};
if ("editor" in window) {
// @ts-ignore
config.dragMode = window.editor.getModel().getDragMode();
}
;
var mouseFetch = this.mousePosFetcher; var mouseFetch = this.mousePosFetcher;
var attrName = 'data-' + config.prefix + 'handler'; var attrName = 'data-' + config.prefix + 'handler';
var rect = this.getElementPos(el, { avoidFrameZoom: true, avoidFrameOffset: true }); var rect = this.getElementPos(el, { avoidFrameZoom: true, avoidFrameOffset: true });
@@ -53891,11 +53896,15 @@ var Resizer = /** @class */ (function () {
var startW = unitWidth === '%' ? (startDim.w / 100) * parentW : startDim.w; var startW = unitWidth === '%' ? (startDim.w / 100) * parentW : startDim.w;
var startH = unitHeight === '%' ? (startDim.h / 100) * parentH : startDim.h; var startH = unitHeight === '%' ? (startDim.h / 100) * parentH : startDim.h;
var box = { var box = {
t: startDim.t - parentRect.top, t: startDim.t,
l: startDim.l - parentRect.left, l: startDim.l,
w: startW, w: startW,
h: startH, h: startH,
}; };
if (!(this.opts.dragMode === 'absolute')) {
box.l += parentRect.left;
box.t += parentRect.top;
}
if (!data) if (!data)
return; return;
var attr = data.handlerAttr; var attr = data.handlerAttr;

2
dist/grapes.mjs.map vendored

File diff suppressed because one or more lines are too long

4
dist/index.d.ts vendored
View File

@@ -4060,6 +4060,10 @@ export interface ResizerOptions {
* Where to append resize container (default body element). * Where to append resize container (default body element).
*/ */
appendTo?: HTMLElement; appendTo?: HTMLElement;
/**
* Drag mode
*/
dragMode?: "absolute" | "relative";
} }
export type Handlers = Record<string, HTMLElement | null>; export type Handlers = Record<string, HTMLElement | null>;
declare class Resizer { declare class Resizer {