Skip to content

Commit

Permalink
fix: set originX left
Browse files Browse the repository at this point in the history
  • Loading branch information
zhe-he committed Sep 2, 2024
1 parent c1054f1 commit 5e1acc1
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions extensions/aligning_guidelines/util/collect-point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ export function collectVerticalPoint(props: CollectPointProps) {
activeObject.set('width', width * sx);
if (isUniform) activeObject.set('height', height * sx);
}
const dx = getDisByOriginX(activeObject, v * dirX);
const dx = getDisByOriginX(activeObject, v, dirX);
if (isUniform) {
const h = activeObject._getTransformedDimensions().y - dim.y;
const dy = getDisByOriginY(activeObject, h * dirY);
const dy = getDisByOriginY(activeObject, h, dirY);
activeObject.set('top', top + dy);
}
activeObject.set('left', left + dx);
Expand Down Expand Up @@ -80,10 +80,10 @@ export function collectHorizontalPoint(props: CollectPointProps) {
activeObject.set('height', height * sy);
if (isUniform) activeObject.set('width', width * sy);
}
const dy = getDisByOriginY(activeObject, v * dirY);
const dy = getDisByOriginY(activeObject, v, dirY);
if (isUniform) {
const w = activeObject._getTransformedDimensions().x - dim.x;
const dx = getDisByOriginX(activeObject, w * dirX);
const dx = getDisByOriginX(activeObject, w, dirX);
activeObject.set('left', left + dx);
}
activeObject.set('top', top + dy);
Expand Down Expand Up @@ -111,13 +111,13 @@ function getDistanceList(point: Point, list: Point[], type: 'x' | 'y') {
return { dis, arr };
}

function getDisByOriginX(target: FabricObject, v: number) {
const dArr = [0, v / 2, v];
if (v < 0) dArr.reverse();
function getDisByOriginX(target: FabricObject, v: number, dir: -1 | 1) {
const dArr = [0, (v / 2) * dir, v * dir];
if (dir == -1) dArr.reverse();
return dArr[originXArr.indexOf(target.originX)];
}
function getDisByOriginY(target: FabricObject, v: number) {
const dArr = [0, v / 2, v];
if (v < 0) dArr.reverse();
function getDisByOriginY(target: FabricObject, v: number, dir: -1 | 1) {
const dArr = [0, (v / 2) * dir, v * dir];
if (dir == -1) dArr.reverse();
return dArr[originYArr.indexOf(target.originY)];
}

0 comments on commit 5e1acc1

Please sign in to comment.