mobile: disable contextmenu only for mobile devices (#243)

This commit is contained in:
Huang Xin
2025-01-24 23:11:05 +01:00
committed by GitHub
parent 6c6af63ecc
commit ae60606470
@@ -128,11 +128,16 @@ const Annotator: React.FC<{ bookKey: string }> = ({ bookKey }) => {
detail.doc?.addEventListener('pointerup', handlePointerup);
detail.doc?.addEventListener('touchmove', handleTouchmove);
detail.doc?.addEventListener('selectionchange', handleSelectionchange);
detail.doc?.addEventListener('contextmenu', (event: Event) => {
event.preventDefault();
event.stopPropagation();
return false;
});
// Disable the default context menu on mobile devices,
// although it should but doesn't work on iOS
if (osPlatform === 'android' || osPlatform === 'ios') {
detail.doc?.addEventListener('contextmenu', (event: Event) => {
event.preventDefault();
event.stopPropagation();
return false;
});
}
}
};