From 1c6451b4c73490edb10fbbe094ac8e59d0e6b23a Mon Sep 17 00:00:00 2001 From: evazion Date: Wed, 29 Jul 2020 20:08:49 -0500 Subject: [PATCH] notes: don't show note bodies while dragging. Bug: if you moused over another note while dragging a note, it would trigger a note body popup. This would also happen when drawing out a new note. Also fix the drag box for new notes being drawn behind other notes. --- app/javascript/src/javascripts/notes.js | 10 +++++++++- app/javascript/src/styles/specific/notes.scss | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/javascript/src/javascripts/notes.js b/app/javascript/src/javascripts/notes.js index 24399dd12..64f0cb563 100644 --- a/app/javascript/src/javascripts/notes.js +++ b/app/javascript/src/javascripts/notes.js @@ -15,6 +15,7 @@ class Note { // Notes must be at least 10x10 in size so they're big enough to drag and resize. static MIN_NOTE_SIZE = 10; + static dragging = false; static notes = new Set(); static timeouts = []; @@ -80,7 +81,10 @@ class Note { } on_mouseenter() { - this.note.body.show(); + // Don't show note bodies if we mouseover another note while dragging or resizing. + if (!Note.dragging) { + this.note.body.show(); + } } on_mouseleave() { @@ -90,6 +94,7 @@ class Note { on_dragstart() { this.$note_box.addClass("unsaved"); Note.Body.hide_all(); + Note.dragging = true; } // Reset the note box placement after the box is dragged or resized. Dragging the note @@ -103,6 +108,7 @@ class Note { this.place_note(x, y, w, h); this.note.body.show(); + Note.dragging = false; } // Place the note box. The input values are pixel coordinates relative to the full image. @@ -705,6 +711,7 @@ class Note { $(document).on("mouseup.danbooru", Note.TranslationMode.Drag.stop); Note.TranslationMode.Drag.dragStartX = e.pageX; Note.TranslationMode.Drag.dragStartY = e.pageY; + Note.dragging = true; } static drag(e) { @@ -735,6 +742,7 @@ class Note { } static stop() { + Note.dragging = false; $(document).off("mousemove.danbooru", Note.TranslationMode.Drag.drag); $(document).off("mouseup.danbooru", Note.TranslationMode.Drag.stop); diff --git a/app/javascript/src/styles/specific/notes.scss b/app/javascript/src/styles/specific/notes.scss index ae5f3229a..96f32264c 100644 --- a/app/javascript/src/styles/specific/notes.scss +++ b/app/javascript/src/styles/specific/notes.scss @@ -160,7 +160,7 @@ div#note-preview { opacity: 0.6; display: none; background: var(--note-preview-background); - z-index: 100; + z-index: 250; } div.note-edit-dialog {