mirror of
https://github.com/sim1222/misskey.git
synced 2025-08-04 07:26:29 +09:00
🎨
This commit is contained in:
@ -1,23 +1,13 @@
|
||||
import { deviceKind } from '@/scripts/device-kind';
|
||||
|
||||
const isTouchSupported = 'maxTouchPoints' in navigator && navigator.maxTouchPoints > 0;
|
||||
|
||||
export let isTouchUsing = false;
|
||||
export let isTouchUsing = deviceKind === 'tablet' || deviceKind === 'smartphone';
|
||||
|
||||
export let isScreenTouching = false;
|
||||
|
||||
if (isTouchSupported) {
|
||||
if (isTouchSupported && !isTouchUsing) {
|
||||
window.addEventListener('touchstart', () => {
|
||||
// maxTouchPointsなどでの判定だけだと、「タッチ機能付きディスプレイを使っているがマウスでしか操作しない」場合にも
|
||||
// タッチで使っていると判定されてしまうため、実際に一度でもタッチされたらtrueにする
|
||||
isTouchUsing = true;
|
||||
|
||||
isScreenTouching = true;
|
||||
}, { passive: true });
|
||||
|
||||
window.addEventListener('touchend', () => {
|
||||
// 子要素のtouchstartイベントでstopPropagation()が呼ばれると親要素に伝搬されずタッチされたと判定されないため、
|
||||
// touchendイベントでもtouchstartイベントと同様にtrueにする
|
||||
isTouchUsing = true;
|
||||
|
||||
isScreenTouching = false;
|
||||
}, { passive: true });
|
||||
}
|
||||
|
Reference in New Issue
Block a user