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
79 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
42 changes: 42 additions & 0 deletions
42
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,42 @@ | ||
/* | ||
* SPDX-FileCopyrightText: syuilo and misskey-project | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
export const preventLongPressContextMenu = () => { | ||
let touching = false; | ||
let touchCanceled = false; | ||
|
||
const onTouchStart = () => { | ||
touching = true; | ||
touchCanceled = false; | ||
}; | ||
|
||
const onTouchMove = () => { | ||
touching = true; | ||
touchCanceled = false; | ||
}; | ||
|
||
const onTouchEnd = () => { | ||
touching = false; | ||
touchCanceled = false; | ||
}; | ||
|
||
const onTouchCancel = () => { | ||
touching = false; | ||
touchCanceled = true; | ||
}; | ||
|
||
document.addEventListener('touchstart', onTouchStart, { passive: true, capture: true }); | ||
document.addEventListener('touchmove', onTouchMove, { passive: true, capture: true }); | ||
document.addEventListener('touchend', onTouchEnd, { passive: true, capture: true }); | ||
document.addEventListener('touchcancel', onTouchCancel, { passive: true, capture: true }); | ||
document.addEventListener('click', onTouchEnd, { passive: true, capture: true }); | ||
document.addEventListener('contextmenu', (ev) => { | ||
if (touchCanceled || touching) { | ||
ev.preventDefault(); | ||
ev.stopPropagation(); | ||
} | ||
onTouchEnd(); | ||
}, { 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