|
@@ -20,6 +20,7 @@ const MODE_ROTATE = 3;
|
|
|
const MODE_SCALE_WIDTH = 4;
|
|
|
const MODE_SCALE_SCALE = 5;
|
|
|
const MODE_RULER_LINE = 6;
|
|
|
+const MODE_RULER_DRAG = 7;
|
|
|
|
|
|
const MODE_NONE = 0;
|
|
|
|
|
@@ -146,7 +147,8 @@ export class SelectCtrl extends ModuleControl<EditorModule> {
|
|
|
onDocMouseDown(e: MouseEvent) {
|
|
|
this._mouseDownTimestamp = Date.now();
|
|
|
if (!this.pageEl || !this.selCanvas) return;
|
|
|
- if (this.store.textEditingState) return;
|
|
|
+
|
|
|
+
|
|
|
|
|
|
document.addEventListener("mousemove", this.onDocMouseMove, {
|
|
|
capture: true,
|
|
@@ -161,7 +163,10 @@ export class SelectCtrl extends ModuleControl<EditorModule> {
|
|
|
const pageX = e.clientX - box?.left;
|
|
|
const pageY = e.clientY - box?.top;
|
|
|
|
|
|
- this._state = MODE_NONE;
|
|
|
+ const draging = this.assistRuler?.dragTest(e)
|
|
|
+
|
|
|
+
|
|
|
+ this._state = draging ? MODE_RULER_DRAG : MODE_NONE;
|
|
|
|
|
|
const sel = this.selCanvas.getBoundingClientRect();
|
|
|
const selX = e.clientX - sel.left;
|
|
@@ -177,63 +182,66 @@ export class SelectCtrl extends ModuleControl<EditorModule> {
|
|
|
|
|
|
this._downed = true;
|
|
|
this._mouseDownFlag = this.getDivTransformFlag(e.target as any);
|
|
|
- if (!this._mouseDownFlag) {
|
|
|
- //选框点击判断
|
|
|
- let isClickSelRect = false;
|
|
|
- if (this.selected.length > 0) {
|
|
|
- const card = this.store.currStreamCard.$el;
|
|
|
- box = card.getBoundingClientRect();
|
|
|
- const cardX = pageX;
|
|
|
- const cardY = e.clientY - box.top;
|
|
|
- isClickSelRect = this.objContainer?.testClick(cardX, cardY) as boolean;
|
|
|
- if (isClickSelRect) {
|
|
|
- this._state = MODE_MOVING;
|
|
|
+
|
|
|
+ if (!draging) {
|
|
|
+ if (!this._mouseDownFlag) {
|
|
|
+ //选框点击判断
|
|
|
+ let isClickSelRect = false;
|
|
|
+ if (this.selected.length > 0) {
|
|
|
+ const card = this.store.currStreamCard.$el;
|
|
|
+ box = card.getBoundingClientRect();
|
|
|
+ const cardX = pageX;
|
|
|
+ const cardY = e.clientY - box.top;
|
|
|
+ isClickSelRect = this.objContainer?.testClick(cardX, cardY) as boolean;
|
|
|
+ if (isClickSelRect) {
|
|
|
+ this._state = MODE_MOVING;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- if (!isClickSelRect) {
|
|
|
- //点击在选框之外
|
|
|
-
|
|
|
- if (!this._downClickedCompId) {
|
|
|
- //没有点击到组件
|
|
|
- const view = this.viewport?.getBoundingClientRect() as any;
|
|
|
- const isOut =
|
|
|
- e.clientX < view.left ||
|
|
|
- e.clientX > view.right ||
|
|
|
- e.clientY < view.top ||
|
|
|
- e.clientY > view.bottom;
|
|
|
- if (!isOut) {
|
|
|
- this._state = MODE_SEL_RECT;
|
|
|
+ if (!isClickSelRect) {
|
|
|
+ //点击在选框之外
|
|
|
+
|
|
|
+ if (!this._downClickedCompId) {
|
|
|
+ //没有点击到组件
|
|
|
+ const view = this.viewport?.getBoundingClientRect() as any;
|
|
|
+ const isOut =
|
|
|
+ e.clientX < view.left ||
|
|
|
+ e.clientX > view.right ||
|
|
|
+ e.clientY < view.top ||
|
|
|
+ e.clientY > view.bottom;
|
|
|
+ if (!isOut) {
|
|
|
+ this._state = MODE_SEL_RECT;
|
|
|
+ }
|
|
|
}
|
|
|
+ //else {//点击到选框之外的组件, 把时间放到mouseup 时相应.
|
|
|
+ // this._state = MODE_MOVING;
|
|
|
+ // const obj = this.compMap[comps[0].id];
|
|
|
+ // this.selecteObjs([new CompObject(obj)]);
|
|
|
+ // }
|
|
|
}
|
|
|
- //else {//点击到选框之外的组件, 把时间放到mouseup 时相应.
|
|
|
- // this._state = MODE_MOVING;
|
|
|
- // const obj = this.compMap[comps[0].id];
|
|
|
- // this.selecteObjs([new CompObject(obj)]);
|
|
|
- // }
|
|
|
- }
|
|
|
- } else if (this._mouseDownFlag == "rotate") {
|
|
|
- this._state = MODE_ROTATE;
|
|
|
- } else if (this._mouseDownFlag.indexOf("move") > -1) {
|
|
|
- this._state = MODE_MOVING;
|
|
|
- } else if (this._mouseDownFlag.indexOf("scale") > -1) {
|
|
|
- this._state = MODE_SCALE_WIDTH;
|
|
|
- if (
|
|
|
- this.store.selected.length == 1 &&
|
|
|
- this.store.currComp.compKey == "Text"
|
|
|
- ) {
|
|
|
- //拖拽的是文本
|
|
|
- const scaleFlags = [
|
|
|
- "scaleBottomright",
|
|
|
- "scaleBottomleft",
|
|
|
- "scaleTopleft",
|
|
|
- "scaleTopright",
|
|
|
- ];
|
|
|
- if (scaleFlags.indexOf(this._mouseDownFlag) > -1) {
|
|
|
- this._state = MODE_SCALE_SCALE;
|
|
|
+ } else if (this._mouseDownFlag == "rotate") {
|
|
|
+ this._state = MODE_ROTATE;
|
|
|
+ } else if (this._mouseDownFlag.indexOf("move") > -1) {
|
|
|
+ this._state = MODE_MOVING;
|
|
|
+ } else if (this._mouseDownFlag.indexOf("scale") > -1) {
|
|
|
+ this._state = MODE_SCALE_WIDTH;
|
|
|
+ if (
|
|
|
+ this.store.selected.length == 1 &&
|
|
|
+ this.store.currComp.compKey == "Text"
|
|
|
+ ) {
|
|
|
+ //拖拽的是文本
|
|
|
+ const scaleFlags = [
|
|
|
+ "scaleBottomright",
|
|
|
+ "scaleBottomleft",
|
|
|
+ "scaleTopleft",
|
|
|
+ "scaleTopright",
|
|
|
+ ];
|
|
|
+ if (scaleFlags.indexOf(this._mouseDownFlag) > -1) {
|
|
|
+ this._state = MODE_SCALE_SCALE;
|
|
|
+ }
|
|
|
}
|
|
|
+ } else if (this._mouseDownFlag.indexOf("ruler") > -1) {
|
|
|
+ this._state = MODE_RULER_LINE;
|
|
|
}
|
|
|
- } else if (this._mouseDownFlag.indexOf("ruler") > -1) {
|
|
|
- this._state = MODE_RULER_LINE;
|
|
|
}
|
|
|
this._movePreClientX = this._downClientX;
|
|
|
this._movePreClientY = this._downClientY;
|
|
@@ -409,6 +417,10 @@ export class SelectCtrl extends ModuleControl<EditorModule> {
|
|
|
break
|
|
|
case MODE_RULER_LINE:
|
|
|
this.assistRuler?.rulerLineMouseMove(e);
|
|
|
+ break;
|
|
|
+ case MODE_RULER_DRAG:
|
|
|
+ this.assistRuler?.onDragMove(e);
|
|
|
+ break;
|
|
|
}
|
|
|
|
|
|
this._movePreClientY = e.clientY;
|
|
@@ -463,8 +475,9 @@ export class SelectCtrl extends ModuleControl<EditorModule> {
|
|
|
this.moveMouseUp(e, isClick);
|
|
|
} else if (this._state == MODE_RULER_LINE) {
|
|
|
this.assistRuler?.rulerLineMouseUp(e, isClick)
|
|
|
+ }else if (this._state == MODE_RULER_DRAG) {
|
|
|
+ this.assistRuler?.onDragUp(e)
|
|
|
}
|
|
|
-
|
|
|
this._state = MODE_NONE;
|
|
|
this._downed = false;
|
|
|
this._moveSelectUpdated = false;
|