forked from misskey-dev/misskey
-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tms(flask): 長押しによるコンテキストメニューイベントの発行を防ぐ
- Loading branch information
Showing
6 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
packages/frontend/src/scripts/tms/prevent-longpress-contextmenu.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* SPDX-FileCopyrightText: syuilo and misskey-project | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
export const preventLongPressContextMenu = () => { | ||
let touching = false; | ||
let timerId: number | null = null; | ||
|
||
const onTouchStart = () => { | ||
if (timerId != null) { | ||
window.clearTimeout(timerId); | ||
timerId = null; | ||
} | ||
timerId = window.setTimeout(() => { | ||
touching = true; | ||
timerId = null; | ||
}, 100); | ||
}; | ||
|
||
const onTouchEnd = () => { | ||
if (timerId != null) { | ||
window.clearTimeout(timerId); | ||
timerId = null; | ||
} | ||
touching = false; | ||
}; | ||
|
||
document.addEventListener('touchstart', onTouchStart, { passive: true, capture: true }); | ||
document.addEventListener('touchend', onTouchEnd, { passive: true, capture: true }); | ||
document.addEventListener('touchcancel', onTouchEnd, { passive: true, capture: true }); | ||
document.addEventListener('click', onTouchEnd, { passive: true, capture: true }); | ||
document.addEventListener('contextmenu', (ev) => { | ||
if (touching) { | ||
ev.preventDefault(); | ||
ev.stopPropagation(); | ||
} | ||
}, { passive: false, capture: true }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters