aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Vitkov <alexvitkov98@gmail.com>2021-02-13 20:12:28 +0200
committerAlex Vitkov <alexvitkov98@gmail.com>2021-02-13 20:12:28 +0200
commit2bd3557dc89263e50924a41d29e8568fe8d34468 (patch)
tree15cbd2eeed763ad2ad1df6db609ac820967b5134
parentdf1fcd07a15417173404b25b91cb8ac176e421c5 (diff)
downloadfileup-2bd3557dc89263e50924a41d29e8568fe8d34468.tar.gz
qutebrowser compliant dragging
-rw-r--r--css/style.css2
-rw-r--r--loggedin.js26
2 files changed, 22 insertions, 6 deletions
diff --git a/css/style.css b/css/style.css
index f20b121..37e694c 100644
--- a/css/style.css
+++ b/css/style.css
@@ -267,6 +267,7 @@ input[type=submit]:hover {
}
.window {
+ box-sizing: border-box;
margin: 0rem;
padding: 0;
box-shadow: 0 0.8rem 1.3rem rgba(0,0,0,0.2);
@@ -338,6 +339,7 @@ input[type=submit]:hover {
}
.file {
+ box-sizing: border-box;
padding: 0.5rem;
cursor: pointer;
color: #333;
diff --git a/loggedin.js b/loggedin.js
index edc81a7..18f7910 100644
--- a/loggedin.js
+++ b/loggedin.js
@@ -13,6 +13,10 @@ var focus = null;
var context_menu = null;
var dragging = null;
+
+var dragging_candidate = null;
+var dragging_candidate_x, dragging_candidate_y;
+
var dragging_fileview;
var dragging_placeholder = null;
var dragging_offset_x = 0, dragging_offset_y = 0;
@@ -366,15 +370,14 @@ function begin_drag_fileview(e, fileview) {
}
function begin_drag(e, obj) {
-
dragging = obj;
+ dragging_candidate = null;
dragging.classList.add("dragged");
var elemRect = dragging.getBoundingClientRect();
dragging_offset_x = e.clientX - elemRect.left;
dragging_offset_y = -e.clientY + elemRect.top;
-
if (dragging_placeholder)
obj.parentNode.insertBefore(dragging_placeholder, obj);
@@ -455,10 +458,14 @@ function make_window(pwd) {
var h2 = document.createElement('h2');
wnd_html.appendChild(h2);
- //h2.onmousedown = (e) => {
- //begin_drag(e, wnd_html);
- // e.preventDefault();
- //};
+ h2.onmousedown = (e) => {
+ // begin_drag(e, wnd_html);
+ if (!dragging) {
+ dragging_candidate = wnd_html;
+ dragging_candidate_x = e.clientX;
+ dragging_candidate_y = e.clientY;
+ }
+ };
path = document.createElement('div');
path.classList.add('path');
@@ -684,9 +691,16 @@ document.body.onmousemove = (e) => {
dragging.style.left = (e.clientX - dragging_offset_x) + "px";
dragging.style.top = (e.clientY + dragging_offset_y) + "px";
}
+ else if (dragging_candidate) {
+ var d = Math.abs(e.clientX - dragging_candidate_x) + Math.abs(e.clientY - dragging_candidate_y);
+ if (d > 15)
+ begin_drag(e, dragging_candidate);
+ }
}
document.body.onmouseup = (_e) => {
+ if (dragging_candidate)
+ dragging_candidate = null;
if (dragging)
end_drag();
}