@hanology/cham-browser 0.2.2 → 0.2.3
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.
package/package.json
CHANGED
|
@@ -12,7 +12,11 @@ const props = defineProps<{
|
|
|
12
12
|
style?: Record<string, string>
|
|
13
13
|
}>()
|
|
14
14
|
|
|
15
|
-
const emit = defineEmits<{
|
|
15
|
+
const emit = defineEmits<{
|
|
16
|
+
close: []
|
|
17
|
+
tooltipEnter: []
|
|
18
|
+
tooltipLeave: []
|
|
19
|
+
}>()
|
|
16
20
|
const { layout } = useReadingMode()
|
|
17
21
|
const isMobile = computed(() => window.innerWidth < 768)
|
|
18
22
|
|
|
@@ -43,6 +47,8 @@ function onBackdropTouchMove() {
|
|
|
43
47
|
:style="style"
|
|
44
48
|
@click.stop
|
|
45
49
|
@touchmove.stop
|
|
50
|
+
@mouseenter="emit('tooltipEnter')"
|
|
51
|
+
@mouseleave="emit('tooltipLeave')"
|
|
46
52
|
>
|
|
47
53
|
<button v-if="isMobile" class="ann-handle" @click="emit('close')">
|
|
48
54
|
<span class="ann-handle-bar" />
|
|
@@ -152,16 +152,33 @@ const proseSections = computed(() => {
|
|
|
152
152
|
return result
|
|
153
153
|
})
|
|
154
154
|
|
|
155
|
+
let hideTimer: ReturnType<typeof setTimeout> | null = null
|
|
156
|
+
function cancelHide() {
|
|
157
|
+
if (hideTimer) { clearTimeout(hideTimer); hideTimer = null }
|
|
158
|
+
}
|
|
159
|
+
function scheduleHide(delay = 150) {
|
|
160
|
+
cancelHide()
|
|
161
|
+
hideTimer = setTimeout(() => { tooltip.hide(); hideTimer = null }, delay)
|
|
162
|
+
}
|
|
163
|
+
|
|
155
164
|
function handleAnnotationHover(event: MouseEvent, annotations: Annotation[]) {
|
|
165
|
+
cancelHide()
|
|
156
166
|
tooltip.show(event, annotations)
|
|
157
167
|
}
|
|
158
168
|
function handleAnnotationLeave() {
|
|
159
|
-
if (window.innerWidth >= 768)
|
|
169
|
+
if (window.innerWidth >= 768) scheduleHide()
|
|
160
170
|
}
|
|
161
171
|
function handleAnnotationTap(event: MouseEvent, annotations: Annotation[]) {
|
|
172
|
+
cancelHide()
|
|
162
173
|
tooltip.toggle(event, annotations)
|
|
163
174
|
}
|
|
164
|
-
function
|
|
175
|
+
function handleTooltipEnter() {
|
|
176
|
+
cancelHide()
|
|
177
|
+
}
|
|
178
|
+
function handleTooltipLeave() {
|
|
179
|
+
if (window.innerWidth >= 768) scheduleHide()
|
|
180
|
+
}
|
|
181
|
+
function dismissTooltip() { cancelHide(); tooltip.hide() }
|
|
165
182
|
const { getAuthor, loadShared } = useData()
|
|
166
183
|
await loadShared()
|
|
167
184
|
|
|
@@ -321,6 +338,8 @@ function tcy(n: number): string {
|
|
|
321
338
|
:layer-labels="layerLabels"
|
|
322
339
|
:style="tooltip.style"
|
|
323
340
|
@close="dismissTooltip"
|
|
341
|
+
@tooltip-enter="handleTooltipEnter"
|
|
342
|
+
@tooltip-leave="handleTooltipLeave"
|
|
324
343
|
/>
|
|
325
344
|
|
|
326
345
|
<Teleport to="body">
|
|
@@ -443,6 +462,8 @@ function tcy(n: number): string {
|
|
|
443
462
|
:layer-labels="layerLabels"
|
|
444
463
|
:style="tooltip.style"
|
|
445
464
|
@close="dismissTooltip"
|
|
465
|
+
@tooltip-enter="handleTooltipEnter"
|
|
466
|
+
@tooltip-leave="handleTooltipLeave"
|
|
446
467
|
/>
|
|
447
468
|
|
|
448
469
|
<Teleport to="body">
|