Skip to content

Commit

Permalink
Change dragging canvas to use 3 fingers not 2
Browse files Browse the repository at this point in the history
  • Loading branch information
ZXMushroom63 committed Jul 4, 2023
1 parent ff358fc commit 347fecd
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
1 change: 0 additions & 1 deletion css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ html {
user-select: none;
overflow-x: hidden;
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
touch-action: none;
}

#toolbar {
Expand Down
44 changes: 19 additions & 25 deletions scripts/ui/draggableCanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ window.addEventListener("mousedown", (e) => {
}
});
window.addEventListener("touchstart", function (e) {
if (e.touches.length === 2) {
if (e.touches.length === 3) {
e.preventDefault();
scrollingUI.scrolling = true;
scrollingUI.oldX = e.touches[0].clientX;
scrollingUI.oldY = e.touches[0].clientY;
Expand All @@ -30,6 +31,7 @@ window.addEventListener("touchcancel", function () {
});
window.addEventListener("touchmove", function (e) {
if (scrollingUI.scrolling) {
e.preventDefault();
scrollingUI.x += e.touches[0].clientX - scrollingUI.oldX;
scrollingUI.y += e.touches[0].clientY - scrollingUI.oldY;
scrollingUI.oldX = e.touches[0].clientX;
Expand Down Expand Up @@ -66,27 +68,19 @@ function updateScroll() {
}
});
}
document.querySelector("#toolbar").addEventListener("mousedown", function (e) {
if (e.button === 2) {
e.stopPropagation;
e.stopImmediatePropagation();
}
});
document.querySelector("#zoomout").addEventListener("mousedown", function (e) {
if (e.button === 2) {
e.stopPropagation;
e.stopImmediatePropagation();
}
});
document.querySelector("#zoomin").addEventListener("mousedown", function (e) {
if (e.button === 2) {
e.stopPropagation;
e.stopImmediatePropagation();
}
});
document.querySelector("#trashbin").addEventListener("mousedown", function (e) {
if (e.button === 2) {
e.stopPropagation;
e.stopImmediatePropagation();
}
});
["#toolbar", "#zoomout", "#zoomin", "#trashbin"].forEach(selector=>{
var elem = document.querySelector(selector);
elem.addEventListener("mousedown", function (e) {
if (e.button === 2) {
e.stopPropagation;
e.stopImmediatePropagation();
}
});
window.addEventListener("touchstart", function (e) {
if (e.touches.length===3) {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
}
});
})
7 changes: 7 additions & 0 deletions scripts/ui/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ function addNodeToCanvas(nodetype, x, y) {
e.stopImmediatePropagation();
}
});
window.addEventListener("touchstart", function (e) {
if (e.touches.length===3) {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
}
});
var inputs = document.createElement("table");
nodetype.argv.forEach((argv) => {
var tr = document.createElement("tr");
Expand Down

0 comments on commit 347fecd

Please sign in to comment.