|
@@ -2,7 +2,9 @@ import { ModuleControl } from "queenjs";
|
|
|
import { reactive } from "vue";
|
|
|
import { EditorModule } from "../../module";
|
|
|
import { DesignComp } from "../../objects/DesignTemp/DesignComp";
|
|
|
+import { Matrix } from "./Matrix";
|
|
|
import * as transforms from "./transforms";
|
|
|
+import { GroupActionCtrl } from "./GroupCtrl";
|
|
|
|
|
|
type TransHandle = (this: TransferCtrl, e: MouseEvent) => void;
|
|
|
|
|
@@ -20,6 +22,8 @@ export class TransferCtrl extends ModuleControl<EditorModule> {
|
|
|
currObserver?: MutationObserver;
|
|
|
transforms = transforms;
|
|
|
|
|
|
+ groupCtrl = new GroupActionCtrl(this.module);
|
|
|
+
|
|
|
transEvent = {
|
|
|
startX: 0,
|
|
|
startY: 0,
|
|
@@ -41,6 +45,8 @@ export class TransferCtrl extends ModuleControl<EditorModule> {
|
|
|
});
|
|
|
|
|
|
init(pageEl: HTMLElement) {
|
|
|
+ this.groupCtrl.init();
|
|
|
+
|
|
|
this.currComp = this.module.store.currComp;
|
|
|
this.compEl = this.currComp.$el;
|
|
|
this.pageEl = pageEl;
|
|
@@ -104,11 +110,12 @@ export class TransferCtrl extends ModuleControl<EditorModule> {
|
|
|
|
|
|
initStyle() {
|
|
|
if (!this.compEl) return;
|
|
|
-
|
|
|
+
|
|
|
const rect = this.compEl.getBoundingClientRect();
|
|
|
const pageRect = this.pageEl.getBoundingClientRect();
|
|
|
|
|
|
- const transform = getTransform(this.compEl);
|
|
|
+ const matrix = new Matrix();
|
|
|
+ matrix.setFormDiv(this.compEl);
|
|
|
|
|
|
this.transferStyle.width = this.compEl.clientWidth + "px";
|
|
|
this.transferStyle.height = this.compEl.clientHeight + "px";
|
|
@@ -121,7 +128,7 @@ export class TransferCtrl extends ModuleControl<EditorModule> {
|
|
|
translateY: "-50%",
|
|
|
};
|
|
|
}
|
|
|
- this.transferStyle.transform.rotate = transform.rotate;
|
|
|
+ this.transferStyle.transform.rotate = matrix.getRotate() + "deg";
|
|
|
this.transferStyle.transform.translateY =
|
|
|
"-" + this.compEl.clientHeight / 2 + "px";
|
|
|
}
|
|
@@ -133,39 +140,8 @@ export class TransferCtrl extends ModuleControl<EditorModule> {
|
|
|
}
|
|
|
|
|
|
destroy() {
|
|
|
+ this.groupCtrl.destroy();
|
|
|
this.currObserver?.disconnect();
|
|
|
this.resetStyle();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-export function getTransform(el: HTMLElement) {
|
|
|
- const st = getComputedStyle(el, null);
|
|
|
- const tr =
|
|
|
- st.getPropertyValue("-webkit-transform") ||
|
|
|
- st.getPropertyValue("-moz-transform") ||
|
|
|
- st.getPropertyValue("-ms-transform") ||
|
|
|
- st.getPropertyValue("-o-transform") ||
|
|
|
- st.getPropertyValue("transform") ||
|
|
|
- "FAIL";
|
|
|
-
|
|
|
- // console.error("Matrix: " + tr);
|
|
|
-
|
|
|
- if (tr == "none")
|
|
|
- return {
|
|
|
- rotate: "0deg",
|
|
|
- };
|
|
|
-
|
|
|
- // rotation matrix - http://en.wikipedia.org/wiki/Rotation_matrix
|
|
|
-
|
|
|
- const values = tr.split("(")[1].split(")")[0].split(",");
|
|
|
- // console.error("values: ", values);
|
|
|
- const a: any = values[0];
|
|
|
- const b: any = values[1];
|
|
|
- const c: any = values[2];
|
|
|
- const d: any = values[3];
|
|
|
-
|
|
|
- const angle = Math.round(Math.atan2(b, a) * (180 / Math.PI));
|
|
|
- return {
|
|
|
- rotate: `${angle}deg`,
|
|
|
- };
|
|
|
-}
|