3 Commits

Author SHA1 Message Date
Luis Landeiro Ribeiro
6c9fa44fa4 new release fix resize in absolute mode with transforms applied 2026-03-02 22:36:43 +00:00
Luis Landeiro Ribeiro
e727435fb1 bump to version 0.22.15 2026-03-01 23:07:26 +00:00
Luis Landeiro Ribeiro
0cc04b7a6f fix anoying bug with absolute resize making components jump around 2026-03-01 22:58:55 +00:00
4 changed files with 33 additions and 8 deletions

4
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

33
dist/grapes.mjs vendored
View File

@@ -17718,6 +17718,12 @@ var ConvertUnitsToPx;
var resizeEventOpts = { component: component, el: el }; var resizeEventOpts = { component: component, el: el };
var modelToStyle; var modelToStyle;
var elComputedStyle; var elComputedStyle;
// Captured at resize-start; used in updateTarget to compute position deltas
// that are immune to any CSS transform applied on the element.
var startCSSTop = 0;
var startCSSLeft = 0;
var startVisualRelTop = 0;
var startVisualRelLeft = 0;
var toggleBodyClass = function (method, e, opts) { var toggleBodyClass = function (method, e, opts) {
var docs = opts.docs; var docs = opts.docs;
docs && docs &&
@@ -17737,6 +17743,15 @@ var ConvertUnitsToPx;
elComputedStyle = getComputedStyle(el); elComputedStyle = getComputedStyle(el);
var modelStyle = modelToStyle.getStyle(); var modelStyle = modelToStyle.getStyle();
var rectStart = __assign({}, resizer.startDim); var rectStart = __assign({}, resizer.startDim);
// Save original CSS top/left (in px, from computedStyle which excludes transforms)
// and the element's starting visual position relative to its offset-parent.
// These are used in updateTarget to apply a pure delta so that a CSS transform on
// the element does not pollute the top/left style values.
startCSSTop = parseFloat(elComputedStyle['top']) || 0;
startCSSLeft = parseFloat(elComputedStyle['left']) || 0;
var parentRectAtStart = resizer.getParentRect();
startVisualRelTop = resizer.startDim.t - parentRectAtStart.top;
startVisualRelLeft = resizer.startDim.l - parentRectAtStart.left;
var currentWidth = modelStyle[keyWidth]; var currentWidth = modelStyle[keyWidth];
config.autoWidth = keepAutoWidth && currentWidth === 'auto'; config.autoWidth = keepAutoWidth && currentWidth === 'auto';
if (isNaN(parseFloat(currentWidth))) { if (isNaN(parseFloat(currentWidth))) {
@@ -17823,8 +17838,15 @@ var ConvertUnitsToPx;
}); });
} }
if (!skipPositionUpdate && em.getDragMode(component)) { if (!skipPositionUpdate && em.getDragMode(component)) {
style.top = "".concat(rect.t, "px"); // rect.t / rect.l are visual positions from getBoundingClientRect, which
style.left = "".concat(rect.l, "px"); // include any CSS transform on the element. We must not assign them directly
// to top/left (CSS positional properties are transform-agnostic).
// Instead, compute the visual delta from the start position and add it to
// the original CSS values so the transform offset is never double-counted.
var deltaTop = rect.t - startVisualRelTop;
var deltaLeft = rect.l - startVisualRelLeft;
style.top = "".concat(startCSSTop + deltaTop, "px");
style.left = "".concat(startCSSLeft + deltaLeft, "px");
} }
var styleUpdated = false; var styleUpdated = false;
var updateStyle = function (customStyle) { var updateStyle = function (customStyle) {
@@ -55379,8 +55401,11 @@ var Resizer = /** @class */ (function () {
return parentRect; return parentRect;
var offsetParent = el.offsetParent; var offsetParent = el.offsetParent;
// Check if the parent or any ancestor has `position: relative`, `absolute`, `fixed`, or `sticky` // Check if the parent or any ancestor has `position: relative`, `absolute`, `fixed`, or `sticky`
// Use avoidFrameZoom and avoidFrameOffset to match the coordinate system used for startDim
// (set in start() with the same flags), so that the subtraction in calc() produces correct
// relative positions for CSS top/left in absolute mode.
if (offsetParent && offsetParent.tagName !== 'BODY') { if (offsetParent && offsetParent.tagName !== 'BODY') {
parentRect = this.getElementPos(offsetParent); parentRect = this.getElementPos(offsetParent, { avoidFrameZoom: true, avoidFrameOffset: true });
} }
return parentRect; return parentRect;
}; };
@@ -69468,7 +69493,7 @@ var grapesjs = {
plugins: plugins, plugins: plugins,
usePlugin: usePlugin, usePlugin: usePlugin,
// @ts-ignore Will be replaced on build // @ts-ignore Will be replaced on build
version: '0.22.14', version: '0.22.16',
/** /**
* Initialize the editor with passed options * Initialize the editor with passed options
* @param {Object} config Configuration object * @param {Object} config Configuration object

2
dist/grapes.mjs.map vendored

File diff suppressed because one or more lines are too long