forked from vancem/Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontextMenu.html
More file actions
118 lines (97 loc) · 2.97 KB
/
contextMenu.html
File metadata and controls
118 lines (97 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<!doctype html>
<head>
<style>
/********************************************************************/
body {
font-family: "Roboto", san-serif;
}
.center {
text-align: center;
}
.menu {
width: 120px;
z-index: 1;
box-shadow: 0 4px 5px 3px rgba(0, 0, 0, 0.2);
position: fixed;
display: none;
transition: 0.2s display ease-in;
.menu-options {
list-style: none;
padding: 10px 0;
z-index: 1;
.menu-option {
font-weight: 500;
z-index: 1;
font-size: 14px;
padding: 10px 40px 10px 20px;
// border-bottom: 1.5px solid rgba(0, 0, 0, 0.2);
cursor: pointer;
&:hover {
background: rgba(0, 0, 0, 0.2);
}
}
}
}
button {
background: grey;
border: none;
.next {
color: green;
}
&[disabled="false"]:hover {
.next {
color: red;
animation: move 0.5s;
animation-iteration-count: 2;
}
}
}
@keyframes move {
from {
transform: translate(0%);
}
50% {
transform: translate(-40%);
}
to {
transform: transform(0%);
}
}
</style>
</head>
<html>
<body>
<!-- *********************************************************************** -->
<div class="menu" id="menu">
<ul class="menu-options">
<li class="menu-option">Back</li>
<li class="menu-option">Reload</li>
<li class="menu-option">Save</li>
<li class="menu-option">Save As</li>
<li class="menu-option">Inspect</li>
</ul>
</div>
<h3 class="center">Right click to view custom context menu</h3>
<p> Just some ordinary text</p>
<p> Just some ordinary text</p>
<!-- *********************************************************************** -->
<script>
"use strict"; // Tell javaScript to be picky to find more errors
const menu = document.getElementById("menu");
let menuVisible = false;
const toggleMenu = function (command) {
menu.style.display = command === "show" ? "block" : "none";
};
const setPosition = function (left, top) {
menu.style.left = left + "px";
menu.style.top = top + "px";
toggleMenu("show");
};
window.oncontextmenu = function (e) {
e.preventDefault()
setPosition(e.pageX, e.pageY);
return false;
};
</script>
</body>
</html>