Skip to content

Commit

Permalink
小窓を2点タッチでモード切替。normal ⇔ moveResize
Browse files Browse the repository at this point in the history
  • Loading branch information
sn0vv committed Feb 20, 2021
1 parent 587985d commit ae51eb3
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/main/lib/draggable.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default class Draggable {
resize: () => {},
finish: () => {},
};
this.touchStatus = "normal";
}

initialize() {
Expand Down Expand Up @@ -167,12 +168,28 @@ export default class Draggable {
makeElementDraggable(mainElement) {
mainElement.addEventListener("dblclick", (e) => this.handleDoubleClick(e));
mainElement.addEventListener("mousedown", (e) => this.handleMouseDown(e));
mainElement.addEventListener("touchstart", (e) => this.handleMouseDown(e));
mainElement.addEventListener("touchstart", (e) => this.handleTouchStart(e));
this.mainElementStyle.set("cursor", "move");
this.current.left = utils.convertToInt(mainElement.style.left);
this.current.top = utils.convertToInt(mainElement.style.top);
}

handleTouchStart(e) {
if(e.touches.length > 1)
{
if(this.touchStatus == "move_resize")
{
this.touchStatus = "normal";
} else {
this.touchStatus = "move_resize";
}
}

if (this.touchStatus == "move_resize" ) {
this.handleMouseDown(e);
}
}

handleDoubleClick(e) {
if (this.selectable) {
return;
Expand Down

0 comments on commit ae51eb3

Please sign in to comment.