oolib 2.132.4 → 2.132.6
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.
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
14
|
if (k2 === undefined) k2 = k;
|
|
4
15
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -30,32 +41,34 @@ var useScreenWidth_1 = require("../../../../utils/customHooks/useScreenWidth");
|
|
|
30
41
|
var AspectRatioShell = function (_a) {
|
|
31
42
|
var id = _a.id, invert = _a.invert, aspectRatio = _a.aspectRatio, children = _a.children, stretchToFullHeight = _a.stretchToFullHeight, containerShape = _a.containerShape, disableImageBorder = _a.disableImageBorder, onShellPrepared = _a.onShellPrepared;
|
|
32
43
|
var wrapperRef = (0, react_1.useRef)(null);
|
|
33
|
-
var _b = (0, react_1.useState)(
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
var _b = (0, react_1.useState)({ width: 'auto', height: 'auto' }), dimensions = _b[0], setDimensions = _b[1];
|
|
45
|
+
var updateDimensions = function () {
|
|
46
|
+
if (wrapperRef.current) {
|
|
47
|
+
if (stretchToFullHeight) {
|
|
48
|
+
var newWidth_1 = wrapperRef.current.clientHeight * (0, calcAspectRatio_1.calcAspectRatio)(aspectRatio);
|
|
49
|
+
setDimensions(function (prev) { return (__assign(__assign({}, prev), { width: "".concat(newWidth_1, "px") })); });
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
var newHeight_1 = wrapperRef.current.offsetWidth / (0, calcAspectRatio_1.calcAspectRatio)(aspectRatio);
|
|
53
|
+
setDimensions(function (prev) { return (__assign(__assign({}, prev), { height: "".concat(newHeight_1, "px") })); });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
43
56
|
};
|
|
44
57
|
(0, react_1.useLayoutEffect)(function () {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
handleSetWrapperHeight();
|
|
58
|
+
updateDimensions();
|
|
59
|
+
var resizeObserver = new ResizeObserver(updateDimensions);
|
|
60
|
+
if (wrapperRef.current) {
|
|
61
|
+
resizeObserver.observe(wrapperRef.current);
|
|
50
62
|
}
|
|
51
|
-
|
|
63
|
+
return function () { return resizeObserver.disconnect(); };
|
|
64
|
+
}, [aspectRatio, stretchToFullHeight]);
|
|
52
65
|
(0, react_1.useEffect)(function () {
|
|
53
|
-
if (
|
|
66
|
+
if (dimensions.width !== 'auto' || dimensions.height !== 'auto') {
|
|
54
67
|
//means the shell is ready with the proper dimensions
|
|
55
68
|
onShellPrepared && onShellPrepared(); //we use this fn. in imageEditor to trigger off the decision on toolbar style
|
|
56
69
|
}
|
|
57
|
-
}, [
|
|
58
|
-
(0, useScreenWidth_1.useScreenWidth)(
|
|
59
|
-
return (react_1.default.createElement(styled_1.StyledAspectRatioWrapper, { id: 'StyledAspectRatioWrapper', ref: wrapperRef, width: stretchToFullHeight ?
|
|
70
|
+
}, [dimensions, onShellPrepared]);
|
|
71
|
+
(0, useScreenWidth_1.useScreenWidth)(updateDimensions);
|
|
72
|
+
return (react_1.default.createElement(styled_1.StyledAspectRatioWrapper, { id: 'StyledAspectRatioWrapper', ref: wrapperRef, width: stretchToFullHeight ? dimensions.width : "100%", height: stretchToFullHeight ? "100%" : dimensions.height, containerShape: containerShape, invert: invert, disableImageBorder: disableImageBorder }, children));
|
|
60
73
|
};
|
|
61
74
|
exports.default = AspectRatioShell;
|
|
@@ -38,8 +38,17 @@ var SliderShell = function (_a) {
|
|
|
38
38
|
var _b = (0, ImageInputContext_1.useImageInputContext)(), aspectRatio = _b.aspectRatio, isLoading = _b.isLoading, imageUnderEdit = _b.imageUnderEdit;
|
|
39
39
|
var wrapperRef = (0, react_1.useRef)(null);
|
|
40
40
|
var _c = (0, react_1.useState)(undefined), imageMinusCaptionHeight = _c[0], setImageMinusCaptionHeight = _c[1];
|
|
41
|
+
var updateHeight = function () {
|
|
42
|
+
if (wrapperRef.current) {
|
|
43
|
+
setImageMinusCaptionHeight(wrapperRef.current.clientWidth / (0, calcAspectRatio_1.calcAspectRatio)(aspectRatio));
|
|
44
|
+
}
|
|
45
|
+
};
|
|
41
46
|
(0, react_1.useEffect)(function () {
|
|
42
|
-
|
|
47
|
+
updateHeight();
|
|
48
|
+
window.addEventListener('resize', updateHeight);
|
|
49
|
+
return function () {
|
|
50
|
+
window.removeEventListener('resize', updateHeight);
|
|
51
|
+
};
|
|
43
52
|
}, []);
|
|
44
53
|
return (react_1.default.createElement(styled_1.StyledFlexWrapper, { ref: wrapperRef },
|
|
45
54
|
value.map(function (v, idx) { return (react_1.default.createElement(styled_1.StyledFlexItem, { key: (v === null || v === void 0 ? void 0 : v.publicUrl) || idx, marginLeft: idx === 0 && activeIdx * -100 + "%" }, render(v, idx) /* explicitly called, cuz we want an error to throw if render prop aint passed thru */)); }),
|