Skip to content

Commit

Permalink
fixed position calculation when dragging of all kinds of items inside…
Browse files Browse the repository at this point in the history
… of external component
  • Loading branch information
ishubin committed Dec 1, 2024
1 parent 7648eaa commit 7c593ed
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/ui/components/editor/Component.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ export function loadAndMountExternalComponent(schemeContainer, userEventBus, ite

schemeContainer.indexUserEventsForItems(item._childItems, userEventBus, compilerErrorCallback);

const parentShadowTransform = schemeContainer.shadowTransform ? schemeContainer.shadowTransform : myMath.identityMatrix();
const shadowTransform = myMath.standardTransformWithArea(
myMath.multiplyMatrices(schemeContainer.shadowTransform, rectItem.meta.transformMatrix),
myMath.multiplyMatrices(parentShadowTransform, rectItem.meta.transformMatrix),
rectItem.area
);
componentSchemeContainer.setShadowTransform(shadowTransform);
Expand Down
4 changes: 2 additions & 2 deletions src/ui/scheme/ItemMath.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export function calculateScreenTransformForArea(area, width, height) {
}

/**
*
*
* @param {Number} x
* @param {Number} y
* @param {Item} item
Expand All @@ -79,7 +79,7 @@ export function worldPointOnItem(x, y, item, transformMatrix = null) {
}

/**
*
*
* @param {Number} x
* @param {Number} y
* @param {Item} item
Expand Down
8 changes: 7 additions & 1 deletion src/ui/scheme/SchemeContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ const minSpatialIndexDistance = 20;
// user a possibility to completelly dettach the connector
const connectorStickyThreshold = 50;


const WORLD_AREA = { x: 0, y: 0, w: 1, h: 1, r: 0, sx: 1, sy: 1, px: 0, py: 0 };

export const DEFAULT_ITEM_MODIFICATION_CONTEXT = {
id: '',
moved: true,
Expand Down Expand Up @@ -370,7 +373,7 @@ class SchemeContainer {
// the component item root. This is needed to correctly convert child component items
// to the global world transform (e.g. when dragging items in view mode,
// or converting mouse coords to local item coords)
this.shadowTransform = myMath.identityMatrix();
this.shadowTransform = null;

// stores all snapping rules for items (used when user drags an item)
this.relativeSnappers = {
Expand Down Expand Up @@ -1434,6 +1437,9 @@ class SchemeContainer {
}
}

if (this.shadowTransform) {
return myMath.localPointInArea(x, y, WORLD_AREA, this.shadowTransform);
}
return {x, y};
}

Expand Down

0 comments on commit 7c593ed

Please sign in to comment.