Skip to content

Commit

Permalink
starting context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
KontrollFreek committed May 23, 2023
1 parent c4ad0d0 commit e176a6b
Show file tree
Hide file tree
Showing 13 changed files with 76 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "geode-studio",
"private": true,
"version": "0.0.3",
"version": "0.0.2",
"type": "module",
"scripts": {
"tauri": "tauri"
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "geode-studio"
version = "0.0.1"
version = "0.0.2"
description = "A Tauri App"
authors = ["you"]
license = ""
Expand Down
4 changes: 2 additions & 2 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"package": {
"productName": "geode-studio",
"version": "0.0.1"
"version": "0.0.2"
},
"tauri": {
"allowlist": {
Expand Down Expand Up @@ -64,4 +64,4 @@
}
]
}
}
}
6 changes: 6 additions & 0 deletions src/css/content.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@
left: 0px;
right: 0px;
bottom: 0px;
overflow: hidden;
}
#content canvas {
position: absolute;
width: 1200px;
height: 1200px;
}/*# sourceMappingURL=content.css.map */
2 changes: 1 addition & 1 deletion src/css/content.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/css/content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@
left: 0px;
right: 0px;
bottom: 0px;
overflow: hidden;

canvas {
position: absolute;
width: 1200px;
height: 1200px;
}
}
11 changes: 11 additions & 0 deletions src/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,15 @@ body {
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
font-weight: 400;
font-size: 12px;
}

#context {
position: absolute;
display: flex;
z-index: 100;
background: #222;
border-radius: 8px;
box-shadow: 4px 4px 14px rgba(0, 0, 0, 0.4);
min-width: 50px;
min-height: 50px;
}/*# sourceMappingURL=main.css.map */
2 changes: 1 addition & 1 deletion src/css/main.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions src/css/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,15 @@ body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
font-weight: 400;
font-size: 12px;
}

#context {
position: absolute;
display: flex;
z-index: 100;
background: #222;
border-radius: 8px;
box-shadow: 4px 4px 14px #0006;
min-width: 50px;
min-height: 50px;
}
7 changes: 6 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<title>Geode Studio</title>

<script type="module" type="text/javascript" src="/js/title.js" defer></script>
<script type="module" type="text/javascript" src="/js/main.js" defer></script>

<link rel="stylesheet" href="/css/main.css" />
<link rel="stylesheet" href="/css/title.css" />
Expand Down Expand Up @@ -33,6 +34,10 @@
</span>
</div>

<div id="content"></div>
<div style="display: none; pointer-events: none;" id="context"></div>

<div id="content">
<canvas data-context></canvas>
</div>
</body>
</html>
Empty file added src/js/canvas.js
Empty file.
28 changes: 28 additions & 0 deletions src/js/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
let context = document.querySelector('#context')

function hideContext() {
context.style.display = 'none'
context.style.pointerEvent = 'none'
}

document.addEventListener('contextmenu', e => {
e.preventDefault()

if (e.target.dataset.context == undefined) return hideContext()

context.style.display = ''
context.style.pointerEvent = ''

context.style.top = e.clientY + 10 + 'px'
context.style.left = e.clientX + 10 + 'px'

let bounding = context.getBoundingClientRect()

if (bounding.bottom >= (window.innerHeight - 5 || document.documentElement.clientHeight - 5))
context.style.top = e.clientY - bounding.height + 'px'

if (bounding.right >= (window.innerWidth - 5 || document.documentElement.clientWidth - 5))
context.style.left = e.clientX - bounding.width + 'px'
})

document.addEventListener('click', hideContext)

0 comments on commit e176a6b

Please sign in to comment.