Skip to content

Commit

Permalink
fix: scale by anchor
Browse files Browse the repository at this point in the history
  • Loading branch information
Jocs committed Jul 5, 2024
1 parent f26140d commit 1c6f2aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export class DocDrawingUpdateRenderController extends Disposable implements IRen
if (width > DRAWING_IMAGE_WIDTH_LIMIT || height > DRAWING_IMAGE_HEIGHT_LIMIT) {
const scaleWidth = DRAWING_IMAGE_WIDTH_LIMIT / width;
const scaleHeight = DRAWING_IMAGE_HEIGHT_LIMIT / height;
scale = Math.max(scaleWidth, scaleHeight);
scale = Math.min(scaleWidth, scaleHeight);
}

const docTransform = this._getImagePosition(width * scale, height * scale);
Expand Down
9 changes: 5 additions & 4 deletions packages/engine-render/src/scene.transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,7 @@ export class Transformer extends Disposable implements ITransformerConfig {
this._topScenePointerMoveSub = topScene.onPointerMove$.subscribeEvent((moveEvt: IPointerEvent | IMouseEvent) => {
const { offsetX: moveOffsetX, offsetY: moveOffsetY } = moveEvt;
this._anchorMoving(type, moveOffsetX, moveOffsetY, scrollTimer, keepRatio, isCropper, applyObject);

scrollTimer.scrolling(moveOffsetX, moveOffsetY, () => {
this._anchorMoving(type, moveOffsetX, moveOffsetY, scrollTimer, keepRatio, isCropper, applyObject);
});
Expand Down Expand Up @@ -967,15 +968,15 @@ export class Transformer extends Disposable implements ITransformerConfig {
if (left + ancestorLeft < this.zeroLeft) {
newTransform.left = -ancestorLeft;
newTransform.width = width + left;
} else if (left + width + ancestorLeft > topSceneWidth) {
newTransform.width = topSceneWidth - left - ancestorLeft;
} else if (left + width + ancestorLeft > topSceneWidth + this.zeroLeft) {
newTransform.width = this.zeroLeft + topSceneWidth - left - ancestorLeft;
}

if (top + ancestorTop < this.zeroTop) {
newTransform.top = -ancestorTop;
newTransform.height = height + top;
} else if (top + height + ancestorTop > topSceneHeight) {
newTransform.height = topSceneHeight - top - ancestorTop;
} else if (top + height + ancestorTop > topSceneHeight + this.zeroTop) {
newTransform.height = this.zeroTop + topSceneHeight - top - ancestorTop;
}

moveObject.transformByState(newTransform);
Expand Down

0 comments on commit 1c6f2aa

Please sign in to comment.