@orfium/ictinus 4.62.3 → 4.63.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.
|
@@ -7,6 +7,8 @@ var _head = _interopRequireDefault(require("lodash/head"));
|
|
|
7
7
|
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
|
|
10
|
+
var _utils = require("./utils");
|
|
11
|
+
|
|
10
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
13
|
|
|
12
14
|
var useHeights = function useHeights(parentRef, itemRef) {
|
|
@@ -29,13 +31,7 @@ var useHeights = function useHeights(parentRef, itemRef) {
|
|
|
29
31
|
|
|
30
32
|
(0, _react.useEffect)(function () {
|
|
31
33
|
if (!parentRef.current) return;
|
|
32
|
-
var parentResizeObserver =
|
|
33
|
-
var parent = (0, _head["default"])(entries);
|
|
34
|
-
|
|
35
|
-
if (parent) {
|
|
36
|
-
setParentHeight(parent.contentRect.height);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
34
|
+
var parentResizeObserver = (0, _utils.resizeObserverHandler)(setParentHeight);
|
|
39
35
|
parentResizeObserver.observe(parentRef.current);
|
|
40
36
|
return function () {
|
|
41
37
|
return parentResizeObserver.disconnect();
|
|
@@ -52,13 +48,7 @@ var useHeights = function useHeights(parentRef, itemRef) {
|
|
|
52
48
|
|
|
53
49
|
var dropdownElement = (0, _head["default"])((_itemRef$current = itemRef.current) == null ? void 0 : _itemRef$current.children);
|
|
54
50
|
if (!dropdownElement) return;
|
|
55
|
-
var childResizeObserver =
|
|
56
|
-
var dropdown = (0, _head["default"])(entries);
|
|
57
|
-
|
|
58
|
-
if (dropdown) {
|
|
59
|
-
setChildHeight(dropdown.contentRect.height);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
51
|
+
var childResizeObserver = (0, _utils.resizeObserverHandler)(setChildHeight);
|
|
62
52
|
childResizeObserver.observe(dropdownElement);
|
|
63
53
|
return function () {
|
|
64
54
|
return childResizeObserver.disconnect();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const resizeObserverHandler: (callback: (args: any) => void) => ResizeObserver;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.resizeObserverHandler = void 0;
|
|
5
|
+
|
|
6
|
+
var _head = _interopRequireDefault(require("lodash/head"));
|
|
7
|
+
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
9
|
+
|
|
10
|
+
var resizeObserverHandler = function resizeObserverHandler(callback) {
|
|
11
|
+
return new ResizeObserver(function (entries) {
|
|
12
|
+
var parent = (0, _head["default"])(entries);
|
|
13
|
+
/** If the event is triggered by the element itself then return
|
|
14
|
+
* to avoid an infinite loop
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
if ((parent == null ? void 0 : parent.target) === (parent == null ? void 0 : parent.contentRect)) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (parent) {
|
|
22
|
+
callback(parent.contentRect.height);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports.resizeObserverHandler = resizeObserverHandler;
|