Добавил реакцию на onwheel

This commit is contained in:
Book Pauk
2019-01-19 01:00:06 +07:00
parent b1a7df1b40
commit ee7c14481b

View File

@@ -1,6 +1,7 @@
<template> <template>
<div ref="main" class="main"> <div ref="main" class="main">
<canvas ref="canvas" class="canvas" @mousedown.prevent="onMouseDown" @touchstart.prevent="onTouchStart" oncontextmenu="return false;"></canvas> <canvas ref="canvas" class="canvas" @mousedown.prevent.stop="onMouseDown" @wheel.prevent.stop="onMouseWheel"
@touchstart.prevent.stop="onTouchStart" oncontextmenu="return false;"></canvas>
</div> </div>
</template> </template>
@@ -329,28 +330,24 @@ class TextPage extends Vue {
onTouchStart(event) { onTouchStart(event) {
if (event.touches.length == 1) { if (event.touches.length == 1) {
const touch = event.touches[0]; const touch = event.touches[0];
const result = this.handleClick(touch.clientX, touch.clientY) this.handleClick(touch.clientX, touch.clientY)
if (result) {
event.stopPropagation();
event.preventDefault();
}
} }
} }
onMouseDown(event) { onMouseDown(event) {
let result = false;
if (event.button == 0) { if (event.button == 0) {
result = this.handleClick(event.clientX, event.clientY); this.handleClick(event.clientX, event.clientY);
} else if (event.button == 2) { } else if (event.button == 2) {
this.doToolBarToggle(); this.doToolBarToggle();
result = true;
} }
}
if (result) { onMouseWheel(event) {
event.stopPropagation(); if (event.deltaY > 0) {
event.preventDefault(); this.doDown();
} else if (event.deltaY < 0) {
this.doUp();
} }
} }