thewellermangroup
commited on
Commit
·
7e4ce91
1
Parent(s):
e376f36
Create CODE/RIGHT_CLICK/RIGHT_CLICK.txt
Browse files
CODE/RIGHT_CLICK/RIGHT_CLICK.txt
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var contextMenu = document.querySelector(".wrapperfortheclick");
|
2 |
+
window.addEventListener("contextmenu", e => {
|
3 |
+
e.preventDefault();
|
4 |
+
let x = e.offsetX, y = e.offsetY,
|
5 |
+
winWidth = document.body.scrollWidth,
|
6 |
+
winHeight = document.body.scrollHeight,
|
7 |
+
cmWidth = contextMenu.offsetWidth,
|
8 |
+
cmHeight = contextMenu.offsetHeight;
|
9 |
+
x = x > winWidth - cmWidth ? winWidth - cmWidth : x;
|
10 |
+
y = y > winHeight - cmHeight ? winHeight - cmHeight : y;
|
11 |
+
contextMenu.style.left = `${x}px`;
|
12 |
+
contextMenu.style.top = `${y}px`;
|
13 |
+
contextMenu.style.visibility = "visible";
|
14 |
+
});
|
15 |
+
document.addEventListener("click", () => contextMenu.style.visibility = "hidden");
|