refactor(frontend): scripts -> utility
This commit is contained in:
parent
f35eb0f6d9
commit
be7e3b9a0c
464 changed files with 829 additions and 829 deletions
22
packages/frontend/src/utility/touch.ts
Normal file
22
packages/frontend/src/utility/touch.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { ref } from 'vue';
|
||||
import { deviceKind } from '@/utility/device-kind.js';
|
||||
|
||||
const isTouchSupported = 'maxTouchPoints' in navigator && navigator.maxTouchPoints > 0;
|
||||
|
||||
export let isTouchUsing = deviceKind === 'tablet' || deviceKind === 'smartphone';
|
||||
|
||||
if (isTouchSupported && !isTouchUsing) {
|
||||
window.addEventListener('touchstart', () => {
|
||||
// maxTouchPointsなどでの判定だけだと、「タッチ機能付きディスプレイを使っているがマウスでしか操作しない」場合にも
|
||||
// タッチで使っていると判定されてしまうため、実際に一度でもタッチされたらtrueにする
|
||||
isTouchUsing = true;
|
||||
}, { passive: true });
|
||||
}
|
||||
|
||||
/** (MkHorizontalSwipe) 横スワイプ中か? */
|
||||
export const isHorizontalSwipeSwiping = ref(false);
|
||||
Loading…
Add table
Add a link
Reference in a new issue