Skip to content
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

Add taphold.js to enable web interface context menu on mobile #774

Closed
wants to merge 2 commits into from

Conversation

zmwangx
Copy link

@zmwangx zmwangx commented Dec 4, 2018

The taphold feature of jquery-ui-contextmenu is meant to be backed by taphold.js, which is currently missing, as observed in #464. This PR adds it.

taphold.js from https://cdn.jsdelivr.net/npm/ui-contextmenu@1.18.1/lib/jquery-taphold/taphold.js; taphold.min.js from https://cdn.jsdelivr.net/npm/ui-contextmenu@1.18.1/lib/jquery-taphold/taphold.min.js (massaged comment to include author and license).

Fixes #464.

@abercrave
Copy link

I came here to submit the very same PR. Happy to see someone else already on it!

@herebcs
Copy link

herebcs commented Dec 10, 2018

Doesn't seem to work from Safari/iPhone X. Just the standard magnifier comes up as before the patch. Wondering why...

@zmwangx
Copy link
Author

zmwangx commented Dec 10, 2018

Okay, yeah.

@abercrave
Copy link

@herebcs, the contextual nav isn’t initialized on mobile devices. That’s any device whose browser’s user agent is matched by the regular expression “(iPhone|iPod|Android)”.

@zmwangx
Copy link
Author

zmwangx commented Dec 10, 2018

Good catch. Kinda funny that it works on the iPad because the user agent test for mobile devices is incomplete.

Anyway, here's the patch to enable context menus on all mobile devices:

diff --git a/web/javascript/transmission.js b/web/javascript/transmission.js
index 4b560ccb3..c3cdedf29 100644
--- a/web/javascript/transmission.js
+++ b/web/javascript/transmission.js
@@ -84,9 +84,10 @@ Transmission.prototype = {
             $('#inspector_link').click($.proxy(this.toggleInspector, this));
 
             this.setupSearchBox();
-            this.createContextMenu();
         };
 
+        this.createContextMenu();
+
         if (this.isMenuEnabled) {
             this.createSettingsMenu();
         };

I guess the rationale to not enable this on mobile is was viewport size, but mainstream phones are so big these days it shouldn't be an issue anymore.

Anyway, I briefly tested this on my iPhone (XS Max, viewport is plenty big for sure), and tap & hold for context menu is hit-and-miss — often enough the info pane is opened when I release my finger. Someone else could look into what mobile-only shenanigans is causing this; the patch is working well enough on my iPad as is, and that's all I ask for.

@zmwangx
Copy link
Author

zmwangx commented Dec 10, 2018

Oh, the patch goes into the PR too, since it's about enabling context menu on mobile, not just iPads.

@herebcs
Copy link

herebcs commented Dec 10, 2018

Thanks guys. Apparently the outcome depends on the position of your finger when you lift it after the long tap. If it is on a menu item then the context menu stays, otherwise (finger between menu items or outside of the context menu) the info pane comes up and you are screwed. Besides that, it works as expected :)

@zmwangx
Copy link
Author

zmwangx commented Dec 10, 2018

If it is on a menu item then the context menu stays, otherwise ...

Not exactly, I can make the context menu stay even when my finger is outside the context menu.

Edit: The trick is to move your finger a little bit while holding. Probably breaks the touch event in some way (not a web dev, especially not on mobile, so not sure).

cfpp2p pushed a commit to cfpp2p/transmission that referenced this pull request Jan 28, 2019
Thanks @zmwangx
transmission/transmission#774
transmission/transmission#464

Implements a tap and hold functionality. Click/tap and hold for 1s (default) triggers taphold event. Click/tap and release triggers normal click event.
cfpp2p pushed a commit to cfpp2p/transmission that referenced this pull request Jan 28, 2019
Thanks @zmwangx
transmission/transmission#774
transmission/transmission#464

Implements a tap and hold functionality. Click/tap and hold for 1s (default) triggers taphold event. Click/tap and release triggers normal click event.
@ckerr
Copy link
Member

ckerr commented Jan 26, 2022

This is fixed as part of #1476, so I'm closing this issue.

@ckerr ckerr closed this Jan 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

Web Interface - Context Menu From Touch Devices
4 participants