Skip to content

Commit 49461a4

Browse files
fix: drop widgets in center of document in mobile view
1 parent 52f37b0 commit 49461a4

File tree

4 files changed

+20
-23
lines changed

4 files changed

+20
-23
lines changed

apps/OpenSign/src/components/pdf/RenderPdf.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,8 @@ function RenderPdf({
364364
</React.Fragment>
365365
);
366366
})
367-
: xyPostion.map((data, ind) => {
367+
: !pdfDetails?.[0]?.IsCompleted &&
368+
xyPostion.map((data, ind) => {
368369
return (
369370
<React.Fragment key={ind}>
370371
{data.pageNumber === pageNumber &&

apps/OpenSign/src/pages/PlaceHolderSign.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -479,14 +479,12 @@ function PlaceHolderSign() {
479479
const widgetHeight = defaultWidthHeight(dragTypeValue).height;
480480
//adding and updating drop position in array when user drop signature button in div
481481
if (item === "onclick") {
482+
const divHeight = divRef.current.getBoundingClientRect().height;
483+
// `getBoundingClientRect()` is used to get accurate measurement height of the div
482484
const dropObj = {
483485
//onclick put placeholder center on pdf
484-
xPosition:
485-
(containerWH.width / 2 - widgetWidth / 2) /
486-
(containerScale * scale),
487-
yPosition:
488-
(containerWH.height / 2 - widgetHeight / 2) /
489-
(containerScale * scale),
486+
xPosition: widgetWidth / 4 + containerWH.width / 2,
487+
yPosition: widgetHeight + divHeight / 2,
490488
isStamp:
491489
(dragTypeValue === "stamp" || dragTypeValue === "image") && true,
492490
key: key,

apps/OpenSign/src/pages/SignyourselfPdf.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -415,28 +415,28 @@ function SignYourSelf() {
415415
pageNumber,
416416
containerWH
417417
);
418+
console.log("container", widgetTypeExist, dragTypeValue, widgetValue);
418419
//adding and updating drop position in array when user drop signature button in div
419420
if (item === "onclick") {
421+
// `getBoundingClientRect()` is used to get accurate measurement height of the div
422+
const divHeight = divRef.current.getBoundingClientRect().height;
420423
const getWidth = widgetTypeExist
421424
? calculateInitialWidthHeight(dragTypeValue, widgetValue).getWidth
422-
: dragTypeValue === "initials"
423-
? defaultWidthHeight(dragTypeValue).width
424-
: "";
425+
: defaultWidthHeight(dragTypeValue).width;
425426
const getHeight = widgetTypeExist
426427
? calculateInitialWidthHeight(dragTypeValue, widgetValue).getHeight
427-
: dragTypeValue === "initials"
428-
? defaultWidthHeight(dragTypeValue).height
429-
: "";
428+
: defaultWidthHeight(dragTypeValue).height;
429+
430430
dropObj = {
431-
xPosition: containerWH.width / 2,
432-
yPosition: containerWH.height / 2,
431+
xPosition: getWidth / 2 + containerWH.width / 2,
432+
yPosition: getHeight + divHeight / 2,
433433
isStamp:
434434
(dragTypeValue === "stamp" || dragTypeValue === "image") && true,
435435
key: key,
436436
type: dragTypeValue,
437437
scale: containerScale,
438-
Width: getWidth / (containerScale * scale),
439-
Height: getHeight / (containerScale * scale),
438+
Width: getWidth,
439+
Height: getHeight,
440440
options: addWidgetOptions(dragTypeValue)
441441
};
442442
dropData.push(dropObj);

apps/OpenSign/src/pages/TemplatePlaceholder.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -384,14 +384,12 @@ const TemplatePlaceholder = () => {
384384
currentPagePosition;
385385
let placeHolder;
386386
if (item === "onclick") {
387+
// `getBoundingClientRect()` is used to get accurate measurement height of the div
388+
const divHeight = divRef.current.getBoundingClientRect().height;
387389
const dropObj = {
388390
//onclick put placeholder center on pdf
389-
xPosition:
390-
(containerWH.width / 2 - widgetWidth / 2) /
391-
(containerScale * scale),
392-
yPosition:
393-
(containerWH.height / 2 - widgetHeight / 2) /
394-
(containerScale * scale),
391+
xPosition: widgetWidth / 4 + containerWH.width / 2,
392+
yPosition: widgetHeight + divHeight / 2,
395393
isStamp:
396394
(dragTypeValue === "stamp" || dragTypeValue === "image") && true,
397395
key: key,

0 commit comments

Comments
 (0)