Skip to content

Commit 9b295f7

Browse files
authored
Merge pull request #158 from raktima-opensignlabs/placeholder-mobile-view2
2 parents fe90711 + bfae7f2 commit 9b295f7

File tree

1 file changed

+41
-12
lines changed
  • microfrontends/SignDocuments/src/Component/component

1 file changed

+41
-12
lines changed

microfrontends/SignDocuments/src/Component/component/renderPdf.js

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,42 @@ function RenderPdf({
4242
const isMobile = window.innerWidth < 767;
4343
const newWidth = window.innerWidth;
4444
const scale = isMobile ? pdfOriginalWidth / newWidth : 1;
45+
46+
// handle signature block width and height according to screen
47+
const posWidth = (pos) => {
48+
let width;
49+
if (isMobile) {
50+
if (!pos.isMobile) {
51+
width = pos.Width / scale ? pos.Width / scale : 150 / scale;
52+
return width;
53+
} else {
54+
width = pos.Width ? pos.Width : 150;
55+
return width;
56+
}
57+
} else {
58+
width = pos.Width ? pos.Width : 150;
59+
return width;
60+
}
61+
};
62+
const posHeight = (pos) => {
63+
let width;
64+
if (isMobile) {
65+
if (!pos.isMobile) {
66+
width = pos.Height / scale ? pos.Height / scale : 60 / scale;
67+
return width;
68+
} else {
69+
width = pos.Height ? pos.Height : 60;
70+
return width;
71+
}
72+
} else {
73+
width = pos.Height ? pos.Height : 60;
74+
return width;
75+
}
76+
};
4577
//check isGuestSigner is present in local if yes than handle login flow header in mobile view
4678
const isGuestSigner = localStorage.getItem("isGuestSigner");
4779

4880
//function for render placeholder block over pdf document
49-
5081
const checkSignedSignes = (data) => {
5182
const checkSign = signedSigners.filter(
5283
(sign) => sign.objectId === data.signerObjId
@@ -59,7 +90,7 @@ function RenderPdf({
5990
if (isMobile) {
6091
//if pos.isMobile false -- placeholder saved from desktop view then handle position in mobile view divided by scale
6192
if (!pos.isMobile) {
62-
return pos.xPosition / scale;
93+
return pos.xPosition / scale - 20;
6394
}
6495
//pos.isMobile true -- placeholder save from mobile view(small device) handle position in mobile view(small screen) view divided by scale
6596
else {
@@ -137,8 +168,8 @@ function RenderPdf({
137168
borderWidth: "0.2px"
138169
}}
139170
size={{
140-
width: pos.Width ? pos.Width : 150,
141-
height: pos.Height ? pos.Height : 60
171+
width: posWidth(pos),
172+
height: posHeight(pos)
142173
}}
143174
lockAspectRatio={pos.Width && 2.5}
144175
default={{
@@ -208,8 +239,8 @@ function RenderPdf({
208239
y: yPos(pos)
209240
}}
210241
size={{
211-
width: pos.Width ? pos.Width : 150,
212-
height: pos.Height ? pos.Height : 60
242+
width: posWidth(pos),
243+
height: posHeight(pos)
213244
}}
214245
lockAspectRatio={pos.Width ? pos.Width / pos.Height : 2.5}
215246
>
@@ -298,12 +329,11 @@ function RenderPdf({
298329
borderWidth: "0.2px"
299330
}}
300331
size={{
301-
width: pos.Width ? pos.Width : 150,
302-
height: pos.Height ? pos.Height : 60
332+
width: posWidth(pos),
333+
height: posHeight(pos)
303334
}}
304335
lockAspectRatio={pos.Width && 2.5}
305336
//if pos.isMobile false -- placeholder saved from desktop view then handle position in mobile view divide by scale
306-
307337
//else if pos.isMobile true -- placeholder saved from mobile or tablet view then handle position in desktop view divide by scale
308338
default={{
309339
x: !pos.isMobile
@@ -365,14 +395,13 @@ function RenderPdf({
365395
borderWidth: "0.2px"
366396
}}
367397
size={{
368-
width: pos.Width ? pos.Width : 150,
369-
height: pos.Height ? pos.Height : 60
398+
width: posWidth(pos),
399+
height: posHeight(pos)
370400
}}
371401
disableDragging={true}
372402
default={{
373403
//if pos.isMobile false -- placeholder saved from desktop view then handle position in mobile view divide by scale
374404
//else if pos.isMobile true -- placeholder saved from mobile or tablet view then handle position in desktop view divide by scale
375-
376405
x: !pos.isMobile
377406
? pos.xPosition / scale
378407
: pos.xPosition * (pos.scale / scale) - 50,

0 commit comments

Comments
 (0)