Skip to content

Commit 37250f8

Browse files
fix multiple signature location issue after complete signature in signyourself flow
1 parent 9a4bd79 commit 37250f8

File tree

1 file changed

+22
-13
lines changed
  • microfrontends/SignDocuments/src/utils

1 file changed

+22
-13
lines changed

microfrontends/SignDocuments/src/utils/Utils.js

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,8 @@ export const multiSignEmbed = async (
348348
pngUrl,
349349
pdfDoc,
350350
pdfOriginalWidth,
351-
signyourself
351+
signyourself,
352+
containerWH
352353
) => {
353354
for (let i = 0; i < pngUrl.length; i++) {
354355
const pageNo = pngUrl[i].pageNumber;
@@ -385,12 +386,12 @@ export const multiSignEmbed = async (
385386
const imgHeight = imgUrlList[id].Height ? imgUrlList[id].Height : 60;
386387
const imgWidth = imgUrlList[id].Width ? imgUrlList[id].Width : 150;
387388
const isMobile = window.innerWidth < 767;
388-
const newWidth = window.innerWidth - 32;
389+
const newWidth = containerWH.width;
389390
const scale = isMobile ? pdfOriginalWidth / newWidth : 1;
390391
const xPos = (pos) => {
391392
if (signyourself) {
392393
if (isMobile) {
393-
return imgUrlList[id].xPosition * scale + 43;
394+
return imgUrlList[id].xPosition * scale;
394395
} else {
395396
return imgUrlList[id].xPosition;
396397
}
@@ -400,15 +401,15 @@ export const multiSignEmbed = async (
400401
//if pos.isMobile false -- placeholder saved from desktop view then handle position in mobile view divided by scale
401402
if (pos.isMobile) {
402403
const x = pos.xPosition * (pos.scale / scale);
403-
return x * scale + 50;
404+
return x * scale;
404405
} else {
405406
const x = pos.xPosition / scale;
406407
return x * scale;
407408
}
408409
} else {
409410
//else if pos.isMobile true -- placeholder saved from mobile or tablet view then handle position in desktop view divide by scale
410411
if (pos.isMobile) {
411-
const x = pos.xPosition * pos.scale + 50;
412+
const x = pos.xPosition * pos.scale;
412413
return x;
413414
} else {
414415
return pos.xPosition;
@@ -435,9 +436,9 @@ export const multiSignEmbed = async (
435436
//if pos.isMobile false -- placeholder saved from desktop view then handle position in mobile view divided by scale
436437
if (pos.isMobile) {
437438
const y = pos.yPosition * (pos.scale / scale);
438-
return page.getHeight() - y * scale - imgHeight;
439+
return page.getHeight() - y * scale - imgHeight * scale;
439440
} else {
440-
return page.getHeight() - y * scale - imgHeight;
441+
return page.getHeight() - y * scale - imgHeight * scale;
441442
}
442443
} else {
443444
//else if pos.isMobile true -- placeholder saved from mobile or tablet view then handle position in desktop view divide by scale
@@ -519,6 +520,7 @@ export const handleImageResize = (
519520
const getPosData = getXYdata;
520521
const addSignPos = getPosData.map((url, ind) => {
521522
if (url.key === key) {
523+
console.log("url", url);
522524
return {
523525
...url,
524526
Width: !url.isMobile ? ref.offsetWidth * scale : ref.offsetWidth,
@@ -592,22 +594,29 @@ export const handleSignYourselfImageResize = (
592594
position,
593595
xyPostion,
594596
index,
595-
setXyPostion
597+
setXyPostion,
598+
pdfOriginalWidth,
599+
containerWH
596600
) => {
597601
const updateFilter = xyPostion[index].pos.filter(
598602
(data) => data.key === key && data.Width && data.Height
599603
);
604+
// console.log(" position.x", position.x)
605+
const isMobile = window.innerWidth < 767;
606+
const newWidth = containerWH;
607+
const scale = isMobile ? pdfOriginalWidth / newWidth : 1;
600608

601609
if (updateFilter.length > 0) {
602610
const getXYdata = xyPostion[index].pos;
603611
const getPosData = getXYdata;
604612
const addSign = getPosData.map((url, ind) => {
605613
if (url.key === key) {
614+
console.log("url", url);
606615
return {
607616
...url,
608-
Width: ref.offsetWidth,
609-
Height: ref.offsetHeight,
610-
xPosition: position.x
617+
Width: !url.isMobile ? ref.offsetWidth * scale : ref.offsetWidth,
618+
Height: !url.isMobile ? ref.offsetHeight * scale : ref.offsetHeight,
619+
xPosition: position.xpos
611620
};
612621
}
613622
return url;
@@ -630,8 +639,8 @@ export const handleSignYourselfImageResize = (
630639
if (url.key === key) {
631640
return {
632641
...url,
633-
Width: ref.offsetWidth,
634-
Height: ref.offsetHeight
642+
Width: !url.isMobile ? ref.offsetWidth * scale : ref.offsetWidth,
643+
Height: !url.isMobile ? ref.offsetHeight * scale : ref.offsetHeight
635644
};
636645
}
637646
return url;

0 commit comments

Comments
 (0)