|
@@ -6,6 +6,7 @@ import {ref, onMounted, nextTick} from "vue";
|
|
import { RxValue } from "../ReactCtrl/rxValue";
|
|
import { RxValue } from "../ReactCtrl/rxValue";
|
|
import { DisplayObject } from "../SelectCtrl/objects/displayObject";
|
|
import { DisplayObject } from "../SelectCtrl/objects/displayObject";
|
|
import { ObjsContainer } from "../SelectCtrl/ObjsContainer";
|
|
import { ObjsContainer } from "../SelectCtrl/ObjsContainer";
|
|
|
|
+import { settingsStore } from "@queenjs-modules/queditor/module/stores/settings";
|
|
|
|
|
|
|
|
|
|
const KeySpace = 32;
|
|
const KeySpace = 32;
|
|
@@ -21,7 +22,6 @@ export class EditorCtrl extends ModuleControl<EditorModule> {
|
|
},
|
|
},
|
|
|
|
|
|
scale: 1,
|
|
scale: 1,
|
|
- mouse: {x: 0, y: 0},
|
|
|
|
keyCode: -1,
|
|
keyCode: -1,
|
|
|
|
|
|
page: {w: 375, h: 650}
|
|
page: {w: 375, h: 650}
|
|
@@ -40,7 +40,7 @@ export class EditorCtrl extends ModuleControl<EditorModule> {
|
|
EditorRef.value.style.width = this.state.width + "px";
|
|
EditorRef.value.style.width = this.state.width + "px";
|
|
EditorRef.value.style.height = this.state.height + "px";
|
|
EditorRef.value.style.height = this.state.height + "px";
|
|
EditorRef.value.style.position = "absolute";
|
|
EditorRef.value.style.position = "absolute";
|
|
- EditorRef.value.style.backgroundColor = "greenyellow";
|
|
|
|
|
|
+ // EditorRef.value.style.backgroundColor = "greenyellow";
|
|
EditorRef.value.style.left = "0";
|
|
EditorRef.value.style.left = "0";
|
|
EditorRef.value.style.top = "0";
|
|
EditorRef.value.style.top = "0";
|
|
|
|
|
|
@@ -92,19 +92,16 @@ export class EditorCtrl extends ModuleControl<EditorModule> {
|
|
let isMoving = false;
|
|
let isMoving = false;
|
|
let moveX = 0, moveY = 0;
|
|
let moveX = 0, moveY = 0;
|
|
parent.addEventListener("mousemove",(e:MouseEvent)=>{
|
|
parent.addEventListener("mousemove",(e:MouseEvent)=>{
|
|
- this.state.setMouse({x: e.offsetX, y: e.offsetY});
|
|
|
|
-
|
|
|
|
- console.log("move", isMoving);
|
|
|
|
|
|
+ //this.state.setMouse({x: e.offsetX, y: e.offsetY});
|
|
|
|
|
|
if (isMoving) {
|
|
if (isMoving) {
|
|
const xOffset = e.pageX - moveX;
|
|
const xOffset = e.pageX - moveX;
|
|
const yOffset = e.pageY - moveY;
|
|
const yOffset = e.pageY - moveY;
|
|
- console.log(xOffset, yOffset);
|
|
|
|
|
|
+ console.log(this.state.pos, xOffset, yOffset);
|
|
this.state.setPos({x: this.state.pos.x + xOffset, y: this.state.pos.y + yOffset});
|
|
this.state.setPos({x: this.state.pos.x + xOffset, y: this.state.pos.y + yOffset});
|
|
-
|
|
|
|
- moveX = e.pageX;
|
|
|
|
- moveY = e.pageY;
|
|
|
|
}
|
|
}
|
|
|
|
+ moveX = e.pageX;
|
|
|
|
+ moveY = e.pageY;
|
|
});
|
|
});
|
|
|
|
|
|
document.addEventListener("mouseup",(e:MouseEvent)=>{
|
|
document.addEventListener("mouseup",(e:MouseEvent)=>{
|
|
@@ -112,8 +109,8 @@ export class EditorCtrl extends ModuleControl<EditorModule> {
|
|
})
|
|
})
|
|
|
|
|
|
this.state.onScaleChanged((v)=>{
|
|
this.state.onScaleChanged((v)=>{
|
|
- editorLayer.style.transform = `scale(${v})`;
|
|
|
|
editorLayer.style.transformOrigin = "50% 50%";
|
|
editorLayer.style.transformOrigin = "50% 50%";
|
|
|
|
+ editorLayer.style.transform = `scale(${v})`;
|
|
})
|
|
})
|
|
this.state.onPosChanged((v)=>{
|
|
this.state.onPosChanged((v)=>{
|
|
editorLayer.style.left= v.x + "px";
|
|
editorLayer.style.left= v.x + "px";
|
|
@@ -131,6 +128,10 @@ export class EditorCtrl extends ModuleControl<EditorModule> {
|
|
|
|
|
|
window.addEventListener("resize", ()=>this.updateEditorSize());
|
|
window.addEventListener("resize", ()=>this.updateEditorSize());
|
|
this.state.onPageChanged(()=>this.updateCardSize());
|
|
this.state.onPageChanged(()=>this.updateCardSize());
|
|
|
|
+
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ this.updateEditorSize();
|
|
|
|
+ }, 100);
|
|
}
|
|
}
|
|
|
|
|
|
updateCardSize() {
|
|
updateCardSize() {
|
|
@@ -145,12 +146,11 @@ export class EditorCtrl extends ModuleControl<EditorModule> {
|
|
}
|
|
}
|
|
|
|
|
|
updateEditorSize() {
|
|
updateEditorSize() {
|
|
- const page = this.doms.editor.value as HTMLElement;
|
|
|
|
const state = this.state;
|
|
const state = this.state;
|
|
const parent = this.doms.parent.value as HTMLElement;
|
|
const parent = this.doms.parent.value as HTMLElement;
|
|
- const left = ( parent.clientWidth - state.width) / 2.0
|
|
|
|
- const top = (parent.clientHeight - state.height) / 2.0
|
|
|
|
- page.style.left = left + "px";
|
|
|
|
- page.style.top = top + "px";
|
|
|
|
|
|
+ const left = ( parent.clientWidth - state.width) / 2.0;
|
|
|
|
+ const top = (parent.clientHeight - state.height) / 2.0;
|
|
|
|
+
|
|
|
|
+ this.state.setPos({x: left, y: top});
|
|
}
|
|
}
|
|
}
|
|
}
|