@invopop/popui 0.1.101 → 0.1.102
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -21,8 +21,10 @@
|
|
|
21
21
|
let dragMoved = false
|
|
22
22
|
let dragDirection: 1 | -1 = 1
|
|
23
23
|
let activePointerId: number | null = null
|
|
24
|
+
let resizeCommitted = false
|
|
24
25
|
|
|
25
26
|
let isDragging = $state(false)
|
|
27
|
+
let isPointerDown = $state(false)
|
|
26
28
|
let tooltipOpen = $state(false)
|
|
27
29
|
let cursorX = $state(0)
|
|
28
30
|
let cursorY = $state(0)
|
|
@@ -30,8 +32,6 @@
|
|
|
30
32
|
const TOOLTIP_HOVER_DELAY_MS = 700
|
|
31
33
|
const TOOLTIP_CURSOR_OFFSET = 12
|
|
32
34
|
|
|
33
|
-
let tooltipDelay = $derived(isDragging ? Number.MAX_SAFE_INTEGER : TOOLTIP_HOVER_DELAY_MS)
|
|
34
|
-
|
|
35
35
|
let cursorAnchor = $derived.by(() => {
|
|
36
36
|
const x = cursorX
|
|
37
37
|
const y = cursorY
|
|
@@ -40,6 +40,27 @@
|
|
|
40
40
|
}
|
|
41
41
|
})
|
|
42
42
|
|
|
43
|
+
$effect(() => {
|
|
44
|
+
if ((isDragging || isPointerDown) && tooltipOpen) {
|
|
45
|
+
tooltipOpen = false
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
let globalDragStyleEl: HTMLStyleElement | null = null
|
|
50
|
+
|
|
51
|
+
function setGlobalDragStyles() {
|
|
52
|
+
if (globalDragStyleEl) return
|
|
53
|
+
globalDragStyleEl = document.createElement('style')
|
|
54
|
+
globalDragStyleEl.textContent =
|
|
55
|
+
'*, *::before, *::after { cursor: col-resize !important; user-select: none !important; }'
|
|
56
|
+
document.head.appendChild(globalDragStyleEl)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function clearGlobalDragStyles() {
|
|
60
|
+
globalDragStyleEl?.remove()
|
|
61
|
+
globalDragStyleEl = null
|
|
62
|
+
}
|
|
63
|
+
|
|
43
64
|
const POST_DRAG_CLICK_GUARD_MS = 250
|
|
44
65
|
let dragEndTime = 0
|
|
45
66
|
|
|
@@ -63,10 +84,11 @@
|
|
|
63
84
|
window.removeEventListener('pointercancel', onWindowPointerUp)
|
|
64
85
|
activePointerId = null
|
|
65
86
|
}
|
|
66
|
-
|
|
67
|
-
document.body.style.userSelect = ''
|
|
87
|
+
clearGlobalDragStyles()
|
|
68
88
|
isDragging = false
|
|
89
|
+
isPointerDown = false
|
|
69
90
|
sidebar.isResizing = false
|
|
91
|
+
resizeCommitted = false
|
|
70
92
|
if (dragMoved) {
|
|
71
93
|
dragEndTime = Date.now()
|
|
72
94
|
dragMoved = false
|
|
@@ -77,6 +99,7 @@
|
|
|
77
99
|
if (e.pointerId !== activePointerId) return
|
|
78
100
|
cursorX = e.clientX
|
|
79
101
|
cursorY = e.clientY
|
|
102
|
+
if (resizeCommitted) return
|
|
80
103
|
const delta = (e.clientX - dragStartX) * dragDirection
|
|
81
104
|
if (Math.abs(delta) > SIDEBAR_DRAG_THRESHOLD_PX) {
|
|
82
105
|
dragMoved = true
|
|
@@ -87,14 +110,14 @@
|
|
|
87
110
|
if (!dragMoved) return
|
|
88
111
|
if (sidebar.state === 'collapsed') {
|
|
89
112
|
if (delta > 0) {
|
|
90
|
-
|
|
113
|
+
resizeCommitted = true
|
|
91
114
|
sidebar.setOpen(true)
|
|
92
115
|
}
|
|
93
116
|
return
|
|
94
117
|
}
|
|
95
118
|
const targetWidth = dragStartWidthPx + delta
|
|
96
119
|
if (targetWidth < SIDEBAR_WIDTH_ICON_PX) {
|
|
97
|
-
|
|
120
|
+
resizeCommitted = true
|
|
98
121
|
sidebar.resetWidth()
|
|
99
122
|
sidebar.setOpen(false)
|
|
100
123
|
return
|
|
@@ -119,8 +142,9 @@
|
|
|
119
142
|
dragStartX = e.clientX
|
|
120
143
|
dragMoved = false
|
|
121
144
|
activePointerId = e.pointerId
|
|
122
|
-
|
|
123
|
-
|
|
145
|
+
isPointerDown = true
|
|
146
|
+
tooltipOpen = false
|
|
147
|
+
setGlobalDragStyles()
|
|
124
148
|
window.addEventListener('pointermove', onWindowPointerMove)
|
|
125
149
|
window.addEventListener('pointerup', onWindowPointerUp)
|
|
126
150
|
window.addEventListener('pointercancel', onWindowPointerUp)
|
|
@@ -153,7 +177,7 @@
|
|
|
153
177
|
|
|
154
178
|
<TooltipPrimitive.Root
|
|
155
179
|
bind:open={tooltipOpen}
|
|
156
|
-
delayDuration={
|
|
180
|
+
delayDuration={TOOLTIP_HOVER_DELAY_MS}
|
|
157
181
|
disableHoverableContent
|
|
158
182
|
>
|
|
159
183
|
<TooltipPrimitive.Trigger>
|