Skip to content

Commit

Permalink
Merge pull request #216 from VisActor/feat/proportionalScaling
Browse files Browse the repository at this point in the history
Feat/proportional scaling
  • Loading branch information
neuqzxy authored Jan 9, 2025
2 parents 7b4585d + abc933b commit 835e269
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion packages/vstory-editor/src/selection/base-selection.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { IGroup } from '@visactor/vrender-core';
import { createGroup } from '@visactor/vrender-core';
import { createGroup, vglobal } from '@visactor/vrender-core';
import type { IEditActionInfo, IEditSelection, IEditSelectionInfo } from '../interface';
import type { ICharacter } from '@visactor/vstory-core';
import { EditActionEnum, EditEditingState } from '../const';
Expand Down Expand Up @@ -74,6 +74,24 @@ export abstract class BaseSelection implements IEditSelection {
selection: this
});
}
protected keyDown = (event: any) => {
if (!(this._layoutController && event)) {
return;
}
if (event.shiftKey || event.key === 'Shift') {
this._layoutController.defaultProportionalScaling = this._layoutController.proportionalScaling;
this._layoutController.proportionalScaling = true;
}
};
protected keyUp = (event: any) => {
if (!(this._layoutController && event)) {
return;
}
if (event.shiftKey || event.key === 'Shift') {
this._layoutController.proportionalScaling = this._layoutController.defaultProportionalScaling;
}
};

protected activeLayoutController() {
if (!this._layoutController) {
this._layoutController = this.createLayoutController();
Expand All @@ -84,6 +102,8 @@ export abstract class BaseSelection implements IEditSelection {
this.attachController(this._layoutController);
this._layoutController.onActive();
this.updateController();
vglobal.addEventListener('keydown', this.keyDown);
vglobal.addEventListener('keyup', this.keyUp);
}
protected inActiveLayoutController() {
if (!this._layoutController) {
Expand All @@ -93,6 +113,8 @@ export abstract class BaseSelection implements IEditSelection {
this.detachController();

this.edit.setEditGlobalState(EditEditingState.continuingEditing, false);
vglobal.removeEventListener('keydown', this.keyDown);
vglobal.removeEventListener('keyup', this.keyUp);
}

protected attachController(layoutController: ITransformController) {
Expand Down

0 comments on commit 835e269

Please sign in to comment.