Fix location when floating

This commit is contained in:
Benjamin Lu
2026-01-23 03:36:33 -08:00
parent 76b7137fa1
commit ce86b53e87

View File

@@ -10,6 +10,7 @@
</div> </div>
<Panel <Panel
ref="panelRef"
class="pointer-events-auto" class="pointer-events-auto"
:style="style" :style="style"
:class="panelClass" :class="panelClass"
@@ -18,7 +19,7 @@
content: { class: isDocked ? 'p-0' : 'p-1' } content: { class: isDocked ? 'p-0' : 'p-1' }
}" }"
> >
<div ref="panelRef" class="relative flex items-center select-none gap-2"> <div class="relative flex items-center select-none gap-2">
<span <span
ref="dragHandleRef" ref="dragHandleRef"
:class=" :class="
@@ -64,6 +65,7 @@ import { clamp } from 'es-toolkit/compat'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import Panel from 'primevue/panel' import Panel from 'primevue/panel'
import { computed, nextTick, ref, watch } from 'vue' import { computed, nextTick, ref, watch } from 'vue'
import type { ComponentPublicInstance } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import QueueInlineProgress from '@/components/queue/QueueInlineProgress.vue' import QueueInlineProgress from '@/components/queue/QueueInlineProgress.vue'
@@ -93,14 +95,17 @@ const isQueuePanelV2Enabled = computed(() =>
settingsStore.get('Comfy.Queue.QPOV2') settingsStore.get('Comfy.Queue.QPOV2')
) )
const panelRef = ref<HTMLElement | null>(null) const panelRef = ref<ComponentPublicInstance | null>(null)
const panelElement = computed(
() => (panelRef.value?.$el as HTMLElement | undefined) ?? null
)
const dragHandleRef = ref<HTMLElement | null>(null) const dragHandleRef = ref<HTMLElement | null>(null)
const isDocked = useLocalStorage('Comfy.MenuPosition.Docked', true) const isDocked = useLocalStorage('Comfy.MenuPosition.Docked', true)
const storedPosition = useLocalStorage('Comfy.MenuPosition.Floating', { const storedPosition = useLocalStorage('Comfy.MenuPosition.Floating', {
x: 0, x: 0,
y: 0 y: 0
}) })
const { x, y, style, isDragging } = useDraggable(panelRef, { const { x, y, style, isDragging } = useDraggable(panelElement, {
initialValue: { x: 0, y: 0 }, initialValue: { x: 0, y: 0 },
handle: dragHandleRef, handle: dragHandleRef,
containerElement: document.body containerElement: document.body
@@ -117,11 +122,12 @@ watchDebounced(
// Set initial position to bottom center // Set initial position to bottom center
const setInitialPosition = () => { const setInitialPosition = () => {
if (panelRef.value) { const panel = panelElement.value
if (panel) {
const screenWidth = window.innerWidth const screenWidth = window.innerWidth
const screenHeight = window.innerHeight const screenHeight = window.innerHeight
const menuWidth = panelRef.value.offsetWidth const menuWidth = panel.offsetWidth
const menuHeight = panelRef.value.offsetHeight const menuHeight = panel.offsetHeight
if (menuWidth === 0 || menuHeight === 0) { if (menuWidth === 0 || menuHeight === 0) {
return return
@@ -197,11 +203,12 @@ watch(
) )
const adjustMenuPosition = () => { const adjustMenuPosition = () => {
if (panelRef.value) { const panel = panelElement.value
if (panel) {
const screenWidth = window.innerWidth const screenWidth = window.innerWidth
const screenHeight = window.innerHeight const screenHeight = window.innerHeight
const menuWidth = panelRef.value.offsetWidth const menuWidth = panel.offsetWidth
const menuHeight = panelRef.value.offsetHeight const menuHeight = panel.offsetHeight
// Calculate distances to all edges // Calculate distances to all edges
const distanceLeft = lastDragState.value.x const distanceLeft = lastDragState.value.x
@@ -271,7 +278,7 @@ const onMouseLeaveDropZone = () => {
const inlineProgressTarget = computed(() => { const inlineProgressTarget = computed(() => {
if (!visible.value || !isQueuePanelV2Enabled.value) return null if (!visible.value || !isQueuePanelV2Enabled.value) return null
if (isDocked.value) return topMenuContainer ?? null if (isDocked.value) return topMenuContainer ?? null
return panelRef.value return panelElement.value
}) })
// Handle drag state changes // Handle drag state changes