Various mobile fixes
This commit is contained in:
parent
a7009e416e
commit
d2e0ab29f2
5 changed files with 43 additions and 12 deletions
|
@ -137,14 +137,26 @@ export default defineComponent({
|
||||||
onInit(panzoomInstance: any) {
|
onInit(panzoomInstance: any) {
|
||||||
panzoomInstance.setTransformOrigin(null);
|
panzoomInstance.setTransformOrigin(null);
|
||||||
},
|
},
|
||||||
mouseDown(e: MouseEvent, nodeID: number | null = null, draggable = false) {
|
mouseDown(e: MouseEvent | TouchEvent, nodeID: number | null = null, draggable = false) {
|
||||||
if (this.dragging == null) {
|
if (this.dragging == null) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
|
let clientX, clientY;
|
||||||
|
if ("touches" in e) {
|
||||||
|
if (e.touches.length === 1) {
|
||||||
|
clientX = e.touches[0].clientX;
|
||||||
|
clientY = e.touches[0].clientY;
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
clientX = e.clientX;
|
||||||
|
clientY = e.clientY;
|
||||||
|
}
|
||||||
this.lastMousePosition = {
|
this.lastMousePosition = {
|
||||||
x: e.clientX,
|
x: clientX,
|
||||||
y: e.clientY
|
y: clientY
|
||||||
};
|
};
|
||||||
this.dragged = { x: 0, y: 0 };
|
this.dragged = { x: 0, y: 0 };
|
||||||
this.hasDragged = false;
|
this.hasDragged = false;
|
||||||
|
@ -158,15 +170,30 @@ export default defineComponent({
|
||||||
player.layers[this.layer].boards[this.id].selectedAction = null;
|
player.layers[this.layer].boards[this.id].selectedAction = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
drag(e: MouseEvent) {
|
drag(e: MouseEvent | TouchEvent) {
|
||||||
const zoom = (this.getZoomLevel as () => number)();
|
const zoom = (this.getZoomLevel as () => number)();
|
||||||
|
|
||||||
|
let clientX, clientY;
|
||||||
|
if ("touches" in e) {
|
||||||
|
if (e.touches.length === 1) {
|
||||||
|
clientX = e.touches[0].clientX;
|
||||||
|
clientY = e.touches[0].clientY;
|
||||||
|
} else {
|
||||||
|
this.endDragging(this.dragging);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
clientX = e.clientX;
|
||||||
|
clientY = e.clientY;
|
||||||
|
}
|
||||||
|
|
||||||
this.dragged = {
|
this.dragged = {
|
||||||
x: this.dragged.x + (e.clientX - this.lastMousePosition.x) / zoom,
|
x: this.dragged.x + (clientX - this.lastMousePosition.x) / zoom,
|
||||||
y: this.dragged.y + (e.clientY - this.lastMousePosition.y) / zoom
|
y: this.dragged.y + (clientY - this.lastMousePosition.y) / zoom
|
||||||
};
|
};
|
||||||
this.lastMousePosition = {
|
this.lastMousePosition = {
|
||||||
x: e.clientX,
|
x: clientX,
|
||||||
y: e.clientY
|
y: clientY
|
||||||
};
|
};
|
||||||
|
|
||||||
if (Math.abs(this.dragged.x) > 10 || Math.abs(this.dragged.y) > 10) {
|
if (Math.abs(this.dragged.x) > 10 || Math.abs(this.dragged.y) > 10) {
|
||||||
|
|
|
@ -295,7 +295,7 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
mouseDown(e: MouseEvent) {
|
mouseDown(e: MouseEvent | TouchEvent) {
|
||||||
this.$emit("mouseDown", e, this.node.id, this.draggable);
|
this.$emit("mouseDown", e, this.node.id, this.draggable);
|
||||||
},
|
},
|
||||||
mouseUp() {
|
mouseUp() {
|
||||||
|
@ -309,7 +309,7 @@ export default defineComponent({
|
||||||
mouseLeave() {
|
mouseLeave() {
|
||||||
this.hovering = false;
|
this.hovering = false;
|
||||||
},
|
},
|
||||||
performAction(e: MouseEvent, action: BoardNodeAction) {
|
performAction(e: MouseEvent | TouchEvent, action: BoardNodeAction) {
|
||||||
// If the onClick function made this action selected,
|
// If the onClick function made this action selected,
|
||||||
// don't propagate the event (which will deselect everything)
|
// don't propagate the event (which will deselect everything)
|
||||||
if (action.onClick(this.node) || this.board.selectedAction === action) {
|
if (action.onClick(this.node) || this.board.selectedAction === action) {
|
||||||
|
@ -317,7 +317,7 @@ export default defineComponent({
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actionMouseUp(e: MouseEvent, action: BoardNodeAction) {
|
actionMouseUp(e: MouseEvent | TouchEvent, action: BoardNodeAction) {
|
||||||
if (this.board.selectedAction === action) {
|
if (this.board.selectedAction === action) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
|
@ -139,6 +139,7 @@ export default defineComponent({
|
||||||
width: 46px;
|
width: 46px;
|
||||||
display: flex;
|
display: flex;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.overlay-nav {
|
.overlay-nav {
|
||||||
|
@ -169,6 +170,9 @@ export default defineComponent({
|
||||||
|
|
||||||
.nav > .title {
|
.nav > .title {
|
||||||
width: unset;
|
width: unset;
|
||||||
|
flex-shrink: 1;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav .saves,
|
.nav .saves,
|
||||||
|
|
|
@ -167,6 +167,7 @@ const pinAction = {
|
||||||
export default {
|
export default {
|
||||||
id: "main",
|
id: "main",
|
||||||
display: Main,
|
display: Main,
|
||||||
|
minWidth: undefined,
|
||||||
startData() {
|
startData() {
|
||||||
return {
|
return {
|
||||||
openNode: null,
|
openNode: null,
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
body {
|
body {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
min-width: 640px;
|
|
||||||
transition: none;
|
transition: none;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue