Skip to content

Commit c8cfee7

Browse files
committed
refactor(pdf-editor): remove touchend workaround internals
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 369182b commit c8cfee7

1 file changed

Lines changed: 6 additions & 45 deletions

File tree

src/components/PdfEditor/PdfEditor.vue

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,6 @@ type PdfElementsInstance = {
127127
selectedDocIndex?: number
128128
autoFitZoom?: boolean
129129
}
130-
type PdfElementsRuntimeInstance = PdfElementsInstance & {
131-
handleMouseMove?: (event: { type: string, touches: Array<{ clientX: number, clientY: number }> }) => void
132-
finishAdding?: () => void
133-
previewElement?: Record<string, unknown> | null
134-
previewVisible?: boolean
135-
}
136130
137131
defineOptions({
138132
name: 'PdfEditor',
@@ -326,43 +320,6 @@ function scheduleSignerAddedCheck() {
326320
pendingAddCheckTimer = setTimeout(checkSignerAdded, 0)
327321
}
328322
329-
function handleDocumentTouchEnd(event: Event) {
330-
if (pendingAddedObjectCount.value === null) {
331-
return
332-
}
333-
334-
const instance = pdfElements.value as PdfElementsRuntimeInstance | null
335-
const touchEvent = event as TouchEvent
336-
const touchPoint = touchEvent.changedTouches?.[0]
337-
if (!instance || !touchPoint) {
338-
scheduleSignerAddedCheck()
339-
return
340-
}
341-
342-
// Work around mobile tap placement timing in pdf-elements: touchend has no
343-
// touches[0], so preview may never become visible on first tap.
344-
if (instance.isAddingMode && instance.previewElement && !instance.previewVisible && instance.handleMouseMove) {
345-
touchEvent.preventDefault?.()
346-
touchEvent.stopImmediatePropagation?.()
347-
348-
instance.handleMouseMove({
349-
type: 'touchmove',
350-
touches: [{ clientX: touchPoint.clientX, clientY: touchPoint.clientY }],
351-
})
352-
requestAnimationFrame(() => {
353-
requestAnimationFrame(() => {
354-
if (instance.isAddingMode) {
355-
instance.finishAdding?.()
356-
}
357-
scheduleSignerAddedCheck()
358-
})
359-
})
360-
return
361-
}
362-
363-
scheduleSignerAddedCheck()
364-
}
365-
366323
function startAddingSigner(signer: SignerSummaryRecord | SignerDetailRecord | null | undefined, size: { width?: number, height?: number }) {
367324
if (!pdfElements.value || !size?.width || !size?.height) {
368325
return false
@@ -451,11 +408,15 @@ async function waitForPageRender(docIndex: number, pageIndex: number) {
451408
452409
onMounted(() => {
453410
ensurePdfWorker()
454-
document.addEventListener('touchend', handleDocumentTouchEnd)
411+
document.addEventListener('mouseup', scheduleSignerAddedCheck)
412+
document.addEventListener('touchend', scheduleSignerAddedCheck)
413+
document.addEventListener('keyup', scheduleSignerAddedCheck)
455414
})
456415
457416
onBeforeUnmount(() => {
458-
document.removeEventListener('touchend', handleDocumentTouchEnd)
417+
document.removeEventListener('mouseup', scheduleSignerAddedCheck)
418+
document.removeEventListener('touchend', scheduleSignerAddedCheck)
419+
document.removeEventListener('keyup', scheduleSignerAddedCheck)
459420
clearPendingAddCheck()
460421
})
461422

0 commit comments

Comments
 (0)