@capillarytech/creatives-library 8.0.316-alpha.1 → 8.0.316-alpha.2
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/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useLayoutEffect, useMemo, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
const DEFAULT_BOTTOM = '0.83rem';
|
|
4
4
|
|
|
@@ -27,7 +27,7 @@ export const useAiraTriggerPosition = ({
|
|
|
27
27
|
}) => {
|
|
28
28
|
const [bottomOffset, setBottomOffset] = useState(DEFAULT_BOTTOM);
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
useLayoutEffect(() => {
|
|
31
31
|
const wrapperElement = wrapperRef?.current;
|
|
32
32
|
if (!wrapperElement) {
|
|
33
33
|
setBottomOffset(DEFAULT_BOTTOM);
|
|
@@ -47,7 +47,8 @@ export const useAiraTriggerPosition = ({
|
|
|
47
47
|
));
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
updatePosition();
|
|
51
|
+
|
|
51
52
|
let resizeObserver = null;
|
|
52
53
|
|
|
53
54
|
if (window.ResizeObserver) {
|
|
@@ -61,7 +62,6 @@ export const useAiraTriggerPosition = ({
|
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
return () => {
|
|
64
|
-
cancelAnimationFrame(rafId);
|
|
65
65
|
if (resizeObserver) {
|
|
66
66
|
resizeObserver.disconnect();
|
|
67
67
|
}
|
|
@@ -11,12 +11,6 @@ describe('useAiraTriggerPosition', () => {
|
|
|
11
11
|
disconnectMock = jest.fn();
|
|
12
12
|
resizeObserverCallback = null;
|
|
13
13
|
|
|
14
|
-
global.requestAnimationFrame = jest.fn((cb) => {
|
|
15
|
-
cb();
|
|
16
|
-
return 1;
|
|
17
|
-
});
|
|
18
|
-
global.cancelAnimationFrame = jest.fn();
|
|
19
|
-
|
|
20
14
|
global.ResizeObserver = jest.fn((cb) => {
|
|
21
15
|
resizeObserverCallback = cb;
|
|
22
16
|
return {
|