From 33d1f93d9262f31f52516a5e37493fe4f64faef1 Mon Sep 17 00:00:00 2001 From: "A.Olokhtonov" Date: Tue, 21 Mar 2023 22:47:26 +0300 Subject: [PATCH] Better drag/pan --- .gitignore | 2 ++ client/cursor.js | 20 +++++++++++++++----- client/index.js | 6 ++++-- server/data/db.sqlite | Bin 36864 -> 0 bytes server/storage.js | 1 - 5 files changed, 21 insertions(+), 8 deletions(-) delete mode 100644 server/data/db.sqlite diff --git a/.gitignore b/.gitignore index 66a5be4..afc01d3 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ server/images +doca.txt +data/ diff --git a/client/cursor.js b/client/cursor.js index 23ae529..a6ff6f3 100644 --- a/client/cursor.js +++ b/client/cursor.js @@ -3,6 +3,7 @@ function on_down(e) { elements.cursor.classList.add('dhide'); elements.canvas0.classList.add('moving'); storage.state.moving = true; + storage.state.mousedown = true; return; } @@ -11,6 +12,7 @@ function on_down(e) { } if (storage.state.moving) { + storage.state.mousedown = true; return; } @@ -53,7 +55,7 @@ function on_move(e) { storage.current_stroke.push(predraw); fire_event(predraw); - } else if (storage.state.moving) { + } else if (storage.state.moving && storage.state.mousedown) { storage.canvas.offset_x -= e.movementX; storage.canvas.offset_y -= e.movementY; @@ -71,10 +73,14 @@ function on_move(e) { } async function on_up(e) { - if (storage.state.moving && e.button === 1) { - elements.cursor.classList.remove('dhide'); - elements.canvas0.classList.remove('moving'); - storage.state.moving = false; + if (storage.state.moving && (e.button === 1 || e.button === 0)) { + storage.state.mousedown = false; + if (!storage.state.spacedown) { + elements.cursor.classList.remove('dhide'); + elements.canvas0.classList.remove('moving'); + storage.state.moving = false; + return; + } } if (storage.state.drawing && e.button === 0) { @@ -82,6 +88,7 @@ async function on_up(e) { const event = stroke_event(); storage.current_stroke = []; await queue_event(event); + return; } } @@ -90,6 +97,7 @@ function on_keydown(e) { elements.cursor.classList.add('dhide'); elements.canvas0.classList.add('moving'); storage.state.moving = true; + storage.state.spacedown = true; } } @@ -98,6 +106,7 @@ function on_keyup(e) { elements.cursor.classList.remove('dhide'); elements.canvas0.classList.remove('moving'); storage.state.moving = false; + storage.state.spacedown = false; } } @@ -106,6 +115,7 @@ function on_leave(e) { elements.cursor.classList.remove('dhide'); elements.canvas0.classList.remove('moving'); storage.state.moving = false; + storage.state.holding = false; return; } } diff --git a/client/index.js b/client/index.js index 2c78ff8..c754f5a 100644 --- a/client/index.js +++ b/client/index.js @@ -31,6 +31,8 @@ const storage = { 'state': { 'drawing': false, 'moving': false, + 'mousedown': false, + 'spacedown': false, }, 'predraw': {}, @@ -47,8 +49,8 @@ const storage = { 'desk_id': 123, 'canvas': { - 'width': 2000, - 'height': 2000, + 'width': 4096, + 'height': 4096, 'offset_x': 0, 'offset_y': 0, }, diff --git a/server/data/db.sqlite b/server/data/db.sqlite deleted file mode 100644 index 965b93505704593663f69b555f1ece3231dbabd2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 36864 zcmeI(du$X%7y$6^o4M;fpgUlJvlhaN7z-f=Y>b$QTG}lS%N0sViW0DT2OMp$lxq?G zAaJyyw;XKCsvcdC}HwsW59R6|>aTMd0kO$=2sAjf8N4T;B~ zHPVcCw%1=2X~jIUw`nB$tf)53qUI(R#m3lN@$tB{xG3kPJg-@7#1G`5#`9#+XY6 za+|A9A6)c^Ise{3z*pc81VVdD)VRaBYGS1Sw^{-n-sU=78+if$t?pd^>Rsb5TA&_g zbGcj?H0R2=H5w6*nk6IaZ%k2M!8D&=&C;^7j9DEp2hCP8j1^&AW=6!KS_xf#e|aIa zoK=10>06PnD9_uXW&PP4MH9$h+DL!|NPq-LfCNZ@1W14cNPq-LfCM^=K&)Z`?Bgu< z8-EG#n9u)>AR0T%0BIZ~KmsH{0wh2JBtQZrKmsH{0wh2J&eH9tn#OQQDE9kv^1Y$w z{|g{4kPQit011!)36KB@kN^pg011!)36MZ15$IC>$&S*lR$;Ni06N1Jlx zKX#`pldy&b@n^OIe_`8YsFLY(SjVp8X*Q4@V`-)PgXNR0fWfZHS$LbBgH5afwy{Ro z#je0-><>7^oOqP=!egvI9%qlq@HAGlk@zheEAuDdVU~@DWT;}J%d5&ZC+T(dP;6L> z9P98hG-4zChV{T%9VDy;%YT!k724=8&C}bC5HoFF|Fu-CKgN3rqT;{G^ zwqb-`U2nz512|iT5?+ie`D|Rz=i*0v9&Y3FWeDPjd=b9N*Wv=c73c8^8Ft`&z6;Cv zUR=)i$?|>p1>cR67p`8nvcF#EQ_3Y)fR|Z5-elA90q(&eGCaelVKSeN!}$!k&%-BW zn-B34?9CTr9AAaq_&V&)*JBU95&QD@aWLPEDKez<4{(ai^Y9Hgdilo(x6CyeZo&%S zxDvYKT1de6pdWq;{c)!Zd*MN>g8Q%!z6?QF4NGASyan&VCfE#HpaQnS9+}!Nj}OS)L$C~vLm8ZeQaA-A zP$R<`SOWF%nrv^QY;BKh?T8HD!6olcZviM_2QV=CEgKBM6sA8G%;9a(nbO# zKmsH{0wh2JBtQZrKmsH{0-awV&gqa3Li!V$hKP;OEfBYqHpd&9E=O%Vp>&V|GfK%IBToSepMqk-fuChurf5O09gBc zMLB!Z9nZrhp~?Z)eYMn$Z{Yr(%qVKvo$8A{uf<`j2Ij5X|BX}5qf;CJ@w>PzE{LEHkV2?#StF8}}l diff --git a/server/storage.js b/server/storage.js index 0d2730e..2cb21f6 100644 --- a/server/storage.js +++ b/server/storage.js @@ -109,7 +109,6 @@ export function startup() { const res5 = db.query('SELECT COUNT(id) as count FROM sessions').get(); const res6 = db.query('SELECT COUNT(id) as count FROM images').get(); - queries.desks = db.query('SELECT id, sn FROM desks'); queries.events = db.query('SELECT * FROM events'); queries.sessions = db.query('SELECT id, lsn, user_id, desk_id FROM sessions');