@inizioevoke/veeva-astroclm-core 1.4.3 → 1.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
Binary file
|
package/package.json
CHANGED
|
@@ -5,13 +5,15 @@ import esbuild from 'esbuild';
|
|
|
5
5
|
import script from './resize.ts?raw';
|
|
6
6
|
|
|
7
7
|
export interface Props {
|
|
8
|
-
width: number
|
|
9
|
-
height: number
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
scale?: 'down' | 'up' | 'always' | 'never';
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
const {
|
|
13
14
|
width,
|
|
14
|
-
height
|
|
15
|
+
height,
|
|
16
|
+
scale = 'down'
|
|
15
17
|
} = Astro.props;
|
|
16
18
|
|
|
17
19
|
let js: string | undefined;
|
|
@@ -22,7 +24,8 @@ if (BUILD_TARGET === 'veeva' || WEB_SCALING) {
|
|
|
22
24
|
minify: true,
|
|
23
25
|
define: {
|
|
24
26
|
IVA_WIDTH: width.toString(),
|
|
25
|
-
IVA_HEIGHT: height.toString()
|
|
27
|
+
IVA_HEIGHT: height.toString(),
|
|
28
|
+
IVA_SCALE: JSON.stringify(scale)
|
|
26
29
|
}
|
|
27
30
|
});
|
|
28
31
|
js = code;
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
const width: number = IVA_WIDTH;
|
|
8
8
|
// @ts-ignore
|
|
9
9
|
const height: number = IVA_HEIGHT;
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
const scaleMode: 'down' | 'up' | 'always' | 'never' = IVA_SCALE;
|
|
10
12
|
// ----------------------------------------------------------------------------------------------------
|
|
11
13
|
|
|
12
14
|
const scalingWrapper = document.querySelector('.scaling-wrapper') as HTMLElement;
|
|
@@ -24,19 +26,30 @@
|
|
|
24
26
|
const vw = Math.round(visualViewport?.width ?? window.innerWidth);
|
|
25
27
|
const vh = Math.round(visualViewport?.height ?? window.innerHeight);
|
|
26
28
|
let transform: string | undefined;
|
|
27
|
-
|
|
28
|
-
if (
|
|
29
|
-
const scale = Math.min(vw / width, vh / height);
|
|
30
|
-
if (scale !== 1 && lastScale !== scale) {
|
|
31
|
-
lastScale = scale;
|
|
32
|
-
const offsetX = (vw - width * scale) / 2 / scale;
|
|
33
|
-
const offsetY = (vh - height * scale) / 2 / scale;
|
|
34
|
-
transform = `scale(${scale}) translate(${offsetX}px, ${offsetY}px)`;
|
|
35
|
-
}
|
|
36
|
-
} else {
|
|
29
|
+
|
|
30
|
+
if (scaleMode === 'never') {
|
|
37
31
|
transform = 'none';
|
|
32
|
+
} else {
|
|
33
|
+
const smallerThanTarget = vw < width - 1 || vh < height - 1;
|
|
34
|
+
const largerThanTarget = vw > width + 1 || vh > height + 1;
|
|
35
|
+
const shouldScale =
|
|
36
|
+
scaleMode === 'always' ||
|
|
37
|
+
(scaleMode === 'down' && smallerThanTarget) ||
|
|
38
|
+
(scaleMode === 'up' && largerThanTarget);
|
|
39
|
+
|
|
40
|
+
if (shouldScale) {
|
|
41
|
+
const scale = Math.min(vw / width, vh / height);
|
|
42
|
+
if (scale !== 1 && lastScale !== scale) {
|
|
43
|
+
lastScale = scale;
|
|
44
|
+
const offsetX = (vw - width * scale) / 2 / scale;
|
|
45
|
+
const offsetY = (vh - height * scale) / 2 / scale;
|
|
46
|
+
transform = `scale(${scale}) translate(${offsetX}px, ${offsetY}px)`;
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
transform = 'none';
|
|
50
|
+
}
|
|
38
51
|
}
|
|
39
|
-
|
|
52
|
+
|
|
40
53
|
if (transform) {
|
|
41
54
|
document.body.classList[transform === 'none' ? 'remove' : 'add']('scaled');
|
|
42
55
|
scalingWrapper.style.transform = transform;
|