-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iOS context menu does not work #219
Comments
On iOS I have no ability to reach the right-mouse-botton context menu. |
For me it does not work in safari or in the fullscreen app. Tested on iphone and ipad. |
The cause seems to be that Safari on iOS does not support the |
Hmm. I just tried google chrome on iOS, there is also no contextmenu. |
From ChatGPT: Here’s a step-by-step implementation of a context menu that works on the latest iPadOS and iOS. The menu will appear when the user taps and holds an area on the website. Full Example Code: <title>Custom Context Menu</title> <style> body { margin: 0; padding: 0; height: 100vh; display: flex; align-items: center; justify-content: center; background-color: #f5f5f5; }
Tap and Hold Here
Option 1
Option 2
Option 3
How It Works: Features: This implementation ensures the menu is intuitive for touch users and works seamlessly across modern iOS and desktop environments. Let me know if you need further refinements! |
On iOS Safari, long-press gestures often trigger system-level interactions rather than custom context menus defined in JavaScript. Unlike Android, which generally allows right-click-like context menus on long-presses, iOS Safari requires some specific adjustments to enable them. Possible Fixes: Here are some approaches to ensure that your custom context menu works on iOS Safari:
By default, Safari may interpret long-presses as actions for system menus (e.g., image previews). To override this behavior, you should prevent the default touch action. document.addEventListener("contextmenu", function (event) {
Since contextmenu events do not always work reliably on iOS, use touchstart and touchend to detect long-press gestures. let touchTimer; document.addEventListener("touchstart", function (event) { document.addEventListener("touchend", function () { function showCustomMenu(event) {
} This approach ensures that a long press (around 500ms) triggers the custom menu while ignoring quick taps.
Some CSS rules can interfere with touch interactions:
Since iOS 15+, pointerdown is a better alternative for detecting user interactions across devices: document.addEventListener("pointerdown", function (event) { document.addEventListener("pointerup", function () { Conclusion To ensure context menus work reliably in iOS Safari: Would you like a working demo with full HTML/CSS/JS? |
Here’s a fully functional HTML, CSS, and JavaScript implementation of a custom context menu that works on iOS Safari, Android, and desktop browsers. Key Features ✅ Supports iOS Safari (Long Press) Full Code Example <title>Custom Context Menu</title> <style> body { font-family: Arial, sans-serif; height: 100vh; display: flex; align-items: center; justify-content: center; background-color: #f4f4f4; -webkit-touch-callout: none; /* Prevent iOS default menu */ -webkit-user-select: none; /* Disable text selection */ }
How It Works Test It Yourself Would you like additional customization, such as animations or touch gestures? 🚀 |
I tried the last code here https://codepen.io/pen and it worked on iOS 😁 |
I am working on a fix that does not impact map operations such as panning, etc. |
I run the app on iOS and ipadOS full screen after adding it to my home screen. What I miss is to press and hold on the chart to get a direct goto option.
Also the ability to hold and tab the orange dst line to delete it.
The text was updated successfully, but these errors were encountered: