-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show context menu on image right-click
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
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
363c3cb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about touch devices, where the context menu is triggered by a long press instead of a right click?
Also, is it possible that a right-click happens and for whatever reason the "contextmenu" event is then not triggered? This would "leak" the value of "pointer-events" which would remain "none" forever. I'm not sure this can even happen, but you must be very sure that this is 100% guaranteed to be impossible under any circumstances, before you use your hack. (I can think of a case, haven't tested it: an event handler for mousedown from some other code which fires after yours and does
preventDefault()
)And also: what if someone purposefully sets
pointer-events
tonone
(in CSS or javascript) for a reason (can't think of one, but we shouldn't assume something doesn't exist because we can't think of a case)? You may end up "restoring" it toauto
. Again, sounds like it can't normally happen (how would the contextmenu event fire if the element can't be target of a mouse event?) but is it guaranteed to be impossible?Overall, this seems a bad hack. I would rather go to the root of the problem, which is the giant div on top of the image existing in the first place.