Improve drag-and-drop in SenderPdfImageEditor

Replaced the old drag-and-drop implementation with a custom solution using mouse events for better control and precision. Added `_isDragging` state and dynamic cursor updates to enhance user feedback during drag operations.

Introduced grab offset calculations to ensure accurate field positioning relative to the pointer. Added `OnEditorMouseUp` to reset the drag state and `GetPageSize` to retrieve page dimensions, defaulting to A4 if unavailable.

Updated `envelope-editor.js` to include `pageNumber` in `getClickCoordsOnPdfPage` and removed the obsolete `getDropCoordsOnPage` function. Enhanced `EditorCoords` to include `PageNumber` for improved page identification.
This commit is contained in:
2026-09-30 09:20:41 +02:00
parent 0c81d79a9b
commit 513efa0833
2 changed files with 59 additions and 53 deletions

View File

@@ -90,33 +90,8 @@ window.envelopeEditor = {
return {
normX: normX,
normY: normY,
pageIndex: targetIndex
};
},
getDropCoordsOnPage: function (viewerCssClass, pageNumber, clientX, clientY) {
const viewer = document.querySelector('.' + viewerCssClass);
if (!viewer) {
console.warn('[envelopeEditor] viewer not found for class:', viewerCssClass);
return null;
}
const page = viewer.querySelector('[data-editor-page="' + pageNumber + '"]');
if (!page) {
console.warn('[envelopeEditor] page not found:', pageNumber);
return null;
}
const rect = page.getBoundingClientRect();
const clampedX = Math.max(rect.left, Math.min(clientX, rect.right));
const clampedY = Math.max(rect.top, Math.min(clientY, rect.bottom));
const normX = (clampedX - rect.left) / rect.width;
const normY = (clampedY - rect.top) / rect.height;
return {
normX: normX,
normY: normY
pageIndex: targetIndex,
pageNumber: parseInt(targetPage.getAttribute('data-editor-page') || String(targetIndex + 1), 10)
};
}
};