mirror of
https://github.com/ckaczor/HomeMonitor.git
synced 2026-01-13 17:22:54 -05:00
Switch to pointer events
This commit is contained in:
@@ -9,32 +9,32 @@
|
|||||||
|
|
||||||
let interval: NodeJS.Timeout;
|
let interval: NodeJS.Timeout;
|
||||||
|
|
||||||
function mousedown() {
|
function startProgress() {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
|
||||||
increment();
|
incrementProgress();
|
||||||
|
|
||||||
interval = setInterval(increment, props.increment);
|
interval = setInterval(incrementProgress, props.increment);
|
||||||
}
|
}
|
||||||
|
|
||||||
function mouseup() {
|
function stopProgress() {
|
||||||
reset();
|
resetProgress();
|
||||||
}
|
}
|
||||||
|
|
||||||
function reset() {
|
function resetProgress() {
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
|
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
current.value = 0;
|
current.value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function increment() {
|
function incrementProgress() {
|
||||||
current.value = current.value + props.increment;
|
current.value = current.value + props.increment;
|
||||||
|
|
||||||
if (current.value >= props.duration) {
|
if (current.value >= props.duration) {
|
||||||
emit('longPress');
|
emit('longPress');
|
||||||
|
|
||||||
reset();
|
resetProgress();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,8 +50,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<button
|
<button
|
||||||
:class="{ 'loading-button': loading }"
|
:class="{ 'loading-button': loading }"
|
||||||
@mousedown="mousedown"
|
@pointerdown="startProgress"
|
||||||
@mouseup="mouseup">
|
@pointerup="stopProgress">
|
||||||
<span v-show="!loading">
|
<span v-show="!loading">
|
||||||
<slot name="default"></slot>
|
<slot name="default"></slot>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user