feat: スマホのピンチ/スワイプ無効化

This commit is contained in:
Nebel 2020-12-29 14:17:05 +09:00
parent 9d54c18876
commit d18496ff30
2 changed files with 4 additions and 2 deletions

View file

@ -3,7 +3,7 @@
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<title>ぷっちんぐるぐる</title> <title>ぷっちんぐるぐる</title>
<meta name="viewport" content="width=device-width" /> <meta name="viewport" content="width=device-width,user-scalable=no" />
<link rel="icon" href="data:," /> <link rel="icon" href="data:," />
<style> <style>
body { body {

View file

@ -71,6 +71,7 @@ function handleMouseMove(event: { clientX: number; clientY: number }) {
} }
function handleTouchmove(event: TouchEvent) { function handleTouchmove(event: TouchEvent) {
event.preventDefault();
[...event.touches].map(handleMouseMove); [...event.touches].map(handleMouseMove);
} }
@ -107,7 +108,7 @@ function setup() {
function main() { function main() {
renderer.setSize(window.innerWidth, window.innerHeight); renderer.setSize(window.innerWidth, window.innerHeight);
Object.assign(canvas.style, { width: "100vw", height: "100vh" }); Object.assign(canvas.style, { width: "100%", height: "100%" });
root.addEventListener("keydown", handleKeydown); root.addEventListener("keydown", handleKeydown);
root.addEventListener("touchmove", handleTouchmove); root.addEventListener("touchmove", handleTouchmove);
root.addEventListener("keyup", handleMouseMoveEnd); root.addEventListener("keyup", handleMouseMoveEnd);
@ -122,6 +123,7 @@ function main() {
}); });
} }
root.appendChild(canvas); root.appendChild(canvas);
Object.assign(root.style, { overflow: "hidden", overscrollBehavior: "none" });
window.addEventListener("resize", adjustCanvasSize); window.addEventListener("resize", adjustCanvasSize);
setup(); setup();
} }