Fixed phantom timetips.

This commit is contained in:
rainbow napkin 2025-04-09 04:16:28 -04:00
parent c70da9daf1
commit d9d39e1563

View file

@ -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){