From d9d39e15634990a28b581a12854823077cdaf360 Mon Sep 17 00:00:00 2001 From: rainbow napkin Date: Wed, 9 Apr 2025 04:16:28 -0400 Subject: [PATCH] Fixed phantom timetips. --- .../channel/panels/queuePanel/queuePanel.js | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/www/js/channel/panels/queuePanel/queuePanel.js b/www/js/channel/panels/queuePanel/queuePanel.js index 2ee7cbe..a7a15da 100644 --- a/www/js/channel/panels/queuePanel/queuePanel.js +++ b/www/js/channel/panels/queuePanel/queuePanel.js @@ -40,6 +40,9 @@ class queuePanel extends panelObj{ } docSwitch(){ + //Clear timetips + this.killTimetips(); + //Call derived doc switch function super.docSwitch(); @@ -99,6 +102,8 @@ class queuePanel extends panelObj{ closer(){ //Clear any remaining timers clearTimeout(this.timeMarkerTimer); + //Clear timetips + this.killTimetips(); } @@ -722,15 +727,20 @@ class queuePanel extends panelObj{ //enable drag on target dataset event.target.dataset['drag'] = true; + //Kill existing timetips + this.killTimetips(); + //Create a tooltip to show the time we're dragging to const timetip = new canopyUXUtils.tooltip('', false, null, this.ownerDoc); - timetip.tooltip.classList.add('media-tooltip'); + timetip.tooltip.classList.add('media-tooltip','media-timetip'); + timetip.tooltip.addEventListener('mousemove', this.killTimetips.bind(this)); + //Drag entry with mouse this.ownerDoc.body.addEventListener('mousemove', (nestedEvent)=>{(dragEntry.bind(this))(nestedEvent, event.target, timetip)}); //Drop on mouse up - this.ownerDoc.body.addEventListener('mouseup', (nestedEvent)=>{(dropEntry.bind(this))(nestedEvent, event.target, timetip)}); + this.ownerDoc.body.addEventListener('mouseup', (nestedEvent)=>{(dropEntry.bind(this))(nestedEvent, event.target)}); //Disable selection on body this.ownerDoc.body.style.userSelect = 'none'; @@ -834,7 +844,7 @@ class queuePanel extends panelObj{ target.style.top = `${entryTop}px`; } - function dropEntry(event, target, timetip){ + function dropEntry(event, target){ //Gross but works :P if(!target.isConnected || target.dataset['drag'] != "true"){ return; @@ -846,12 +856,27 @@ class queuePanel extends panelObj{ //allow selection on body this.ownerDoc.body.style.userSelect = 'none'; - //Remove timetip - timetip.remove(); + //kill timetips + this.killTimetips(); //Finish dragging target.dataset['drag'] = false; } + + } + + killTimetips(event){ + //If we have an event and it's holding any mouse buttons + if(event != null && event.buttons != 0){ + //Fuck off and die + return; + } + + //Find any existing timetips + for(const timetip of this.ownerDoc.querySelectorAll('.media-timetip')){ + //nukem + timetip.remove(); + } } renderTimeMarker(date = new Date(), forceScroll = false){