@shoutem/ui 9.3.1-rc.1 → 9.3.2-rc.0
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.
- package/html/services/Dimensions.js +18 -9
- package/package.json +1 -1
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
import { Dimensions } from 'react-native';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Returns the width available to HTML content: the window width minus the
|
|
5
|
+
* SimpleHtml container's horizontal padding and `outerPadding`, the horizontal
|
|
6
|
+
* space the parent containers take between the screen edge and SimpleHtml.
|
|
7
|
+
* Embedded images and videos are capped at this width so they don't overflow.
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} style Resolved SimpleHtml style.
|
|
10
|
+
* @param {Object} [style.container] Container style; `paddingLeft` and
|
|
11
|
+
* `paddingRight` (expanded from `padding` by the theme) are subtracted.
|
|
12
|
+
* @param {number} [style.outerPadding] Total horizontal space (both sides)
|
|
13
|
+
* taken by parent containers.
|
|
14
|
+
* @returns {number}
|
|
15
|
+
*/
|
|
3
16
|
export function resolveMaxWidth(style) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
// otherwise maxWidth will be more than max & images will go over the edge
|
|
7
|
-
const parentContainerPadding = style.outerPadding || 0;
|
|
8
|
-
const paddingValue =
|
|
9
|
-
style.container.paddingLeft ||
|
|
10
|
-
0 + style.container.paddingRight ||
|
|
11
|
-
0 + parentContainerPadding;
|
|
17
|
+
const { paddingLeft = 0, paddingRight = 0 } = style.container || {};
|
|
18
|
+
const outerPadding = style.outerPadding || 0;
|
|
12
19
|
|
|
13
|
-
return
|
|
20
|
+
return (
|
|
21
|
+
Dimensions.get('window').width - paddingLeft - paddingRight - outerPadding
|
|
22
|
+
);
|
|
14
23
|
}
|
|
15
24
|
|
|
16
25
|
export function resolveDimensions(objectToResize, style) {
|