@zohodesk/components 1.0.0-temp-243.1 → 1.0.0-temp-242.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/README.md +6 -0
- package/assets/Appearance/dark/mode/Component_DarkMode.module.css +198 -198
- package/assets/Appearance/dark/mode/Component_v1_DarkMode.module.css +8 -8
- package/assets/Appearance/dark/themes/blue/blue_CTA_DarkModifyCategory.module.css +465 -465
- package/assets/Appearance/dark/themes/blue/blue_CTA_DarkTheme.module.css +33 -33
- package/assets/Appearance/dark/themes/blue/blue_ComponentTheme_DarkTheme.module.css +28 -28
- package/assets/Appearance/dark/themes/green/green_CTA_DarkModifyCategory.module.css +465 -465
- package/assets/Appearance/dark/themes/green/green_CTA_DarkTheme.module.css +33 -33
- package/assets/Appearance/dark/themes/green/green_ComponentTheme_DarkTheme.module.css +28 -28
- package/assets/Appearance/dark/themes/orange/orange_CTA_DarkModifyCategory.module.css +465 -465
- package/assets/Appearance/dark/themes/orange/orange_CTA_DarkTheme.module.css +33 -33
- package/assets/Appearance/dark/themes/orange/orange_ComponentTheme_DarkTheme.module.css +28 -28
- package/assets/Appearance/dark/themes/red/red_CTA_DarkModifyCategory.module.css +465 -465
- package/assets/Appearance/dark/themes/red/red_CTA_DarkTheme.module.css +33 -33
- package/assets/Appearance/dark/themes/red/red_ComponentTheme_DarkTheme.module.css +28 -28
- package/assets/Appearance/dark/themes/yellow/yellow_CTA_DarkModifyCategory.module.css +465 -465
- package/assets/Appearance/dark/themes/yellow/yellow_CTA_DarkTheme.module.css +33 -33
- package/assets/Appearance/dark/themes/yellow/yellow_ComponentTheme_DarkTheme.module.css +28 -28
- package/assets/Appearance/light/mode/Component_LightMode.module.css +194 -194
- package/assets/Appearance/light/mode/Component_v1_LightMode.module.css +8 -8
- package/assets/Appearance/light/themes/blue/blue_CTA_LightModifyCategory.module.css +465 -465
- package/assets/Appearance/light/themes/blue/blue_CTA_LightTheme.module.css +33 -33
- package/assets/Appearance/light/themes/blue/blue_ComponentTheme_LightTheme.module.css +28 -28
- package/assets/Appearance/light/themes/green/green_CTA_LightModifyCategory.module.css +465 -465
- package/assets/Appearance/light/themes/green/green_CTA_LightTheme.module.css +33 -33
- package/assets/Appearance/light/themes/green/green_ComponentTheme_LightTheme.module.css +28 -28
- package/assets/Appearance/light/themes/orange/orange_CTA_LightModifyCategory.module.css +465 -465
- package/assets/Appearance/light/themes/orange/orange_CTA_LightTheme.module.css +33 -33
- package/assets/Appearance/light/themes/orange/orange_ComponentTheme_LightTheme.module.css +28 -28
- package/assets/Appearance/light/themes/red/red_CTA_LightModifyCategory.module.css +465 -465
- package/assets/Appearance/light/themes/red/red_CTA_LightTheme.module.css +33 -33
- package/assets/Appearance/light/themes/red/red_ComponentTheme_LightTheme.module.css +28 -28
- package/assets/Appearance/light/themes/yellow/yellow_CTA_LightModifyCategory.module.css +465 -465
- package/assets/Appearance/light/themes/yellow/yellow_CTA_LightTheme.module.css +33 -33
- package/assets/Appearance/light/themes/yellow/yellow_ComponentTheme_LightTheme.module.css +28 -28
- package/assets/Appearance/pureDark/mode/Component_PureDarkMode.module.css +200 -200
- package/assets/Appearance/pureDark/mode/Component_v1_PureDarkMode.module.css +8 -8
- package/assets/Appearance/pureDark/themes/blue/blue_CTA_PureDarkModifyCategory.module.css +465 -465
- package/assets/Appearance/pureDark/themes/blue/blue_CTA_PureDarkTheme.module.css +33 -33
- package/assets/Appearance/pureDark/themes/blue/blue_ComponentTheme_PureDarkTheme.module.css +28 -28
- package/assets/Appearance/pureDark/themes/green/green_CTA_PureDarkModifyCategory.module.css +465 -465
- package/assets/Appearance/pureDark/themes/green/green_CTA_PureDarkTheme.module.css +33 -33
- package/assets/Appearance/pureDark/themes/green/green_ComponentTheme_PureDarkTheme.module.css +28 -28
- package/assets/Appearance/pureDark/themes/orange/orange_CTA_PureDarkModifyCategory.module.css +465 -465
- package/assets/Appearance/pureDark/themes/orange/orange_CTA_PureDarkTheme.module.css +33 -33
- package/assets/Appearance/pureDark/themes/orange/orange_ComponentTheme_PureDarkTheme.module.css +28 -28
- package/assets/Appearance/pureDark/themes/red/red_CTA_PureDarkModifyCategory.module.css +465 -465
- package/assets/Appearance/pureDark/themes/red/red_CTA_PureDarkTheme.module.css +33 -33
- package/assets/Appearance/pureDark/themes/red/red_ComponentTheme_PureDarkTheme.module.css +28 -28
- package/assets/Appearance/pureDark/themes/yellow/yellow_CTA_PureDarkModifyCategory.module.css +465 -465
- package/assets/Appearance/pureDark/themes/yellow/yellow_CTA_PureDarkTheme.module.css +33 -33
- package/assets/Appearance/pureDark/themes/yellow/yellow_ComponentTheme_PureDarkTheme.module.css +28 -28
- package/es/DropBox/DropBoxElement/DropBoxElement.js +1 -1
- package/es/DropBox/utils/isMobilePopover.js +3 -14
- package/es/Popup/Popup.js +21 -1045
- package/es/utils/Common.js +1 -1
- package/es/v1/Popup/Popup.js +1 -1
- package/lib/DropBox/DropBoxElement/DropBoxElement.js +5 -5
- package/lib/DropBox/utils/isMobilePopover.js +4 -14
- package/lib/Popup/Popup.js +25 -1152
- package/lib/utils/Common.js +1 -1
- package/lib/v1/Popup/Popup.js +1 -1
- package/package.json +4 -4
- package/es/DropBox/DropBoxPositionMapping.js +0 -142
- package/es/Popup/PositionMapping.js +0 -72
- package/es/Popup/Registry.js +0 -36
- package/es/Popup/intersectionObserver.js +0 -49
- package/es/Popup/viewPort.js +0 -373
- package/lib/DropBox/DropBoxPositionMapping.js +0 -149
- package/lib/Popup/PositionMapping.js +0 -81
- package/lib/Popup/Registry.js +0 -46
- package/lib/Popup/intersectionObserver.js +0 -72
- package/lib/Popup/viewPort.js +0 -367
package/lib/utils/Common.js
CHANGED
|
@@ -38,7 +38,7 @@ exports.stopAllEventPropagation = exports.scrollTo = void 0;
|
|
|
38
38
|
exports.stopPropagation = stopPropagation;
|
|
39
39
|
exports.throttle = void 0;
|
|
40
40
|
|
|
41
|
-
var _viewPort = _interopRequireDefault(require("
|
|
41
|
+
var _viewPort = _interopRequireDefault(require("@zohodesk/dotkit/es/react/components/Popup/utils/viewPort.js"));
|
|
42
42
|
|
|
43
43
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
44
44
|
|
package/lib/v1/Popup/Popup.js
CHANGED
|
@@ -15,7 +15,7 @@ var _hoistNonReactStatics = _interopRequireDefault(require("hoist-non-react-stat
|
|
|
15
15
|
|
|
16
16
|
var _Common = require("../../utils/Common.js");
|
|
17
17
|
|
|
18
|
-
var _viewPort = _interopRequireDefault(require("
|
|
18
|
+
var _viewPort = _interopRequireDefault(require("@zohodesk/dotkit/es/react/components/Popup/utils/viewPort.js"));
|
|
19
19
|
|
|
20
20
|
var _PositionMapping = require("../../Popup/PositionMapping.js");
|
|
21
21
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/components",
|
|
3
|
-
"version": "1.0.0-temp-
|
|
3
|
+
"version": "1.0.0-temp-242.2",
|
|
4
4
|
"main": "es/index.js",
|
|
5
5
|
"module": "es/index.js",
|
|
6
6
|
"private": false,
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"build:css:umd": "npm run clean && npm run init && react-cli build:css:umd",
|
|
40
40
|
"coverage": "react-cli coverage",
|
|
41
41
|
"prepare": "npm run init && npm run css:build ",
|
|
42
|
-
"prepublishOnly": "node prePublish.js && npm run
|
|
42
|
+
"prepublishOnly": "node prePublish.js && npm run css:review && npm run review:props ",
|
|
43
43
|
"postpublish": "node postPublish.js",
|
|
44
44
|
"report": "react-cli publish:report",
|
|
45
45
|
"test": "react-cli test",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"@testing-library/react": "^11.2.5",
|
|
75
75
|
"@testing-library/react-hooks": "^7.0.2",
|
|
76
76
|
"@testing-library/user-event": "^13.0.10",
|
|
77
|
-
"@zohodesk-private/color-variable-preprocessor": "1.
|
|
77
|
+
"@zohodesk-private/color-variable-preprocessor": "1.2.0",
|
|
78
78
|
"@zohodesk-private/css-variable-migrator": "1.0.9",
|
|
79
79
|
"@zohodesk-private/node-plugins": "1.1.13",
|
|
80
80
|
"@zohodesk-private/react-prop-validator": "1.2.3",
|
|
@@ -113,4 +113,4 @@
|
|
|
113
113
|
"@zohodesk/dotkit": "1.0.3",
|
|
114
114
|
"color": "4.2.3"
|
|
115
115
|
}
|
|
116
|
-
}
|
|
116
|
+
}
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
export const positionMapping = {
|
|
2
|
-
"bottomCenter": {
|
|
3
|
-
"direction": "bottom",
|
|
4
|
-
"arrowPosition": "mid",
|
|
5
|
-
"positionStyle": "bottomMid"
|
|
6
|
-
},
|
|
7
|
-
"bottomLeftToRight": {
|
|
8
|
-
"direction": "bottom",
|
|
9
|
-
"arrowPosition": "start",
|
|
10
|
-
"positionStyle": "bottomEnd"
|
|
11
|
-
},
|
|
12
|
-
"bottomCenterToRight": {
|
|
13
|
-
"direction": "bottom",
|
|
14
|
-
"arrowPosition": "start",
|
|
15
|
-
"positionStyle": "bottomEnd"
|
|
16
|
-
},
|
|
17
|
-
"bottomRightToLeft": {
|
|
18
|
-
"direction": "bottom",
|
|
19
|
-
"arrowPosition": "end",
|
|
20
|
-
"positionStyle": "bottomStart"
|
|
21
|
-
},
|
|
22
|
-
"bottomCenterToLeft": {
|
|
23
|
-
"direction": "bottom",
|
|
24
|
-
"arrowPosition": "end",
|
|
25
|
-
"positionStyle": "bottomStart"
|
|
26
|
-
},
|
|
27
|
-
"topCenter": {
|
|
28
|
-
"direction": "top",
|
|
29
|
-
"arrowPosition": "mid",
|
|
30
|
-
"positionStyle": "topMid"
|
|
31
|
-
},
|
|
32
|
-
"topLeftToRight": {
|
|
33
|
-
"direction": "top",
|
|
34
|
-
"arrowPosition": "start",
|
|
35
|
-
"positionStyle": "topEnd"
|
|
36
|
-
},
|
|
37
|
-
"topCenterToRight": {
|
|
38
|
-
"direction": "top",
|
|
39
|
-
"arrowPosition": "start",
|
|
40
|
-
"positionStyle": "topEnd"
|
|
41
|
-
},
|
|
42
|
-
"topRightToLeft": {
|
|
43
|
-
"direction": "top",
|
|
44
|
-
"arrowPosition": "end",
|
|
45
|
-
"positionStyle": "topStart"
|
|
46
|
-
},
|
|
47
|
-
"topCenterToLeft": {
|
|
48
|
-
"direction": "top",
|
|
49
|
-
"arrowPosition": "end",
|
|
50
|
-
"positionStyle": "topStart"
|
|
51
|
-
},
|
|
52
|
-
"rightCenter": {
|
|
53
|
-
"direction": "right",
|
|
54
|
-
"arrowPosition": "mid",
|
|
55
|
-
"positionStyle": "rightMid"
|
|
56
|
-
},
|
|
57
|
-
"rightTopToBottom": {
|
|
58
|
-
"direction": "right",
|
|
59
|
-
"arrowPosition": "start",
|
|
60
|
-
"positionStyle": "rightEnd"
|
|
61
|
-
},
|
|
62
|
-
"rightCenterToBottom": {
|
|
63
|
-
"direction": "right",
|
|
64
|
-
"arrowPosition": "start",
|
|
65
|
-
"positionStyle": "rightEnd"
|
|
66
|
-
},
|
|
67
|
-
"rightBottomToTop": {
|
|
68
|
-
"direction": "right",
|
|
69
|
-
"arrowPosition": "end",
|
|
70
|
-
"positionStyle": "rightStart"
|
|
71
|
-
},
|
|
72
|
-
"rightCenterToTop": {
|
|
73
|
-
"direction": "right",
|
|
74
|
-
"arrowPosition": "end",
|
|
75
|
-
"positionStyle": "rightStart"
|
|
76
|
-
},
|
|
77
|
-
"leftCenter": {
|
|
78
|
-
"direction": "left",
|
|
79
|
-
"arrowPosition": "mid",
|
|
80
|
-
"positionStyle": "leftMid"
|
|
81
|
-
},
|
|
82
|
-
"leftTopToBottom": {
|
|
83
|
-
"direction": "left",
|
|
84
|
-
"arrowPosition": "start",
|
|
85
|
-
"positionStyle": "leftEnd"
|
|
86
|
-
},
|
|
87
|
-
"leftCenterToBottom": {
|
|
88
|
-
"direction": "left",
|
|
89
|
-
"arrowPosition": "start",
|
|
90
|
-
"positionStyle": "leftEnd"
|
|
91
|
-
},
|
|
92
|
-
"leftBottomToTop": {
|
|
93
|
-
"direction": "left",
|
|
94
|
-
"arrowPosition": "end",
|
|
95
|
-
"positionStyle": "leftStart"
|
|
96
|
-
},
|
|
97
|
-
"leftCenterToTop": {
|
|
98
|
-
"direction": "left",
|
|
99
|
-
"arrowPosition": "end",
|
|
100
|
-
"positionStyle": "leftStart"
|
|
101
|
-
},
|
|
102
|
-
"bottomRight": {
|
|
103
|
-
"direction": "bottom",
|
|
104
|
-
"arrowPosition": "start",
|
|
105
|
-
"positionStyle": "bottomEnd"
|
|
106
|
-
},
|
|
107
|
-
"bottomLeft": {
|
|
108
|
-
"direction": "bottom",
|
|
109
|
-
"arrowPosition": "end",
|
|
110
|
-
"positionStyle": "bottomStart"
|
|
111
|
-
},
|
|
112
|
-
"topRight": {
|
|
113
|
-
"direction": "top",
|
|
114
|
-
"arrowPosition": "start",
|
|
115
|
-
"positionStyle": "topEnd"
|
|
116
|
-
},
|
|
117
|
-
"topLeft": {
|
|
118
|
-
"direction": "top",
|
|
119
|
-
"arrowPosition": "end",
|
|
120
|
-
"positionStyle": "topStart"
|
|
121
|
-
},
|
|
122
|
-
"rightBottom": {
|
|
123
|
-
"direction": "right",
|
|
124
|
-
"arrowPosition": "start",
|
|
125
|
-
"positionStyle": "rightEnd"
|
|
126
|
-
},
|
|
127
|
-
"rightTop": {
|
|
128
|
-
"direction": "right",
|
|
129
|
-
"arrowPosition": "end",
|
|
130
|
-
"positionStyle": "rightStart"
|
|
131
|
-
},
|
|
132
|
-
"leftBottom": {
|
|
133
|
-
"direction": "left",
|
|
134
|
-
"arrowPosition": "start",
|
|
135
|
-
"positionStyle": "leftEnd"
|
|
136
|
-
},
|
|
137
|
-
"leftTop": {
|
|
138
|
-
"direction": "left",
|
|
139
|
-
"arrowPosition": "end",
|
|
140
|
-
"positionStyle": "leftStart"
|
|
141
|
-
}
|
|
142
|
-
};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
export const absolutePositionMapping = {
|
|
2
|
-
"bottomCenter": "bottomCenter",
|
|
3
|
-
"bottomRight": "bottomLeftToRight",
|
|
4
|
-
"bottomLeft": "bottomRightToLeft",
|
|
5
|
-
"topCenter": "topCenter",
|
|
6
|
-
"topRight": "topLeftToRight",
|
|
7
|
-
"topLeft": "topRightToLeft",
|
|
8
|
-
"rightCenter": "rightCenter",
|
|
9
|
-
"rightBottom": "rightTopToBottom",
|
|
10
|
-
"rightTop": "rightBottomToTop",
|
|
11
|
-
"leftCenter": "leftCenter",
|
|
12
|
-
"leftBottom": "leftTopToBottom",
|
|
13
|
-
"leftTop": "leftBottomToTop",
|
|
14
|
-
"bottomLeftToRight": "bottomLeftToRight",
|
|
15
|
-
"bottomRightToLeft": "bottomRightToLeft",
|
|
16
|
-
"topLeftToRight": "topLeftToRight",
|
|
17
|
-
"topRightToLeft": "topRightToLeft",
|
|
18
|
-
"rightTopToBottom": "rightTopToBottom",
|
|
19
|
-
"rightBottomToTop": "rightBottomToTop",
|
|
20
|
-
"leftTopToBottom": "leftTopToBottom"
|
|
21
|
-
};
|
|
22
|
-
export const rtlAbsolutePositionMapping = {
|
|
23
|
-
"bottomCenter": "bottomCenter",
|
|
24
|
-
"bottomRight": "bottomRightToLeft",
|
|
25
|
-
"bottomLeft": "bottomLeftToRight",
|
|
26
|
-
"topCenter": "topCenter",
|
|
27
|
-
"topRight": "topRightToLeft",
|
|
28
|
-
"topLeft": "topLeftToRight",
|
|
29
|
-
"rightCenter": "leftCenter",
|
|
30
|
-
"rightBottom": "leftTopToBottom",
|
|
31
|
-
"rightTop": "leftBottomToTop",
|
|
32
|
-
"leftCenter": "rightCenter",
|
|
33
|
-
"leftBottom": "rightTopToBottom",
|
|
34
|
-
"leftTop": "rightBottomToTop",
|
|
35
|
-
"bottomLeftToRight": "bottomLeftToRight",
|
|
36
|
-
"bottomRightToLeft": "bottomRightToLeft",
|
|
37
|
-
"topLeftToRight": "topLeftToRight",
|
|
38
|
-
"topRightToLeft": "topRightToLeft",
|
|
39
|
-
"rightTopToBottom": "rightTopToBottom",
|
|
40
|
-
"rightBottomToTop": "rightBottomToTop",
|
|
41
|
-
"leftTopToBottom": "leftTopToBottom"
|
|
42
|
-
};
|
|
43
|
-
export const rtlFixedPositionMapping = {
|
|
44
|
-
"bottomCenter": "bottomCenter",
|
|
45
|
-
"bottomLeftToRight": "bottomRightToLeft",
|
|
46
|
-
"bottomCenterToRight": "bottomCenterToLeft",
|
|
47
|
-
"bottomRightToLeft": "bottomLeftToRight",
|
|
48
|
-
"bottomCenterToLeft": "bottomCenterToRight",
|
|
49
|
-
"topCenter": "topCenter",
|
|
50
|
-
"topLeftToRight": "topRightToLeft",
|
|
51
|
-
"topCenterToRight": "topCenterToLeft",
|
|
52
|
-
"topRightToLeft": "topLeftToRight",
|
|
53
|
-
"topCenterToLeft": "topCenterToRight",
|
|
54
|
-
"rightTopToBottom": "leftTopToBottom",
|
|
55
|
-
"rightCenterToBottom": "leftCenterToBottom",
|
|
56
|
-
"rightCenter": "leftCenter",
|
|
57
|
-
"rightBottomToTop": "leftBottomToTop",
|
|
58
|
-
"rightCenterToTop": "leftCenterToTop",
|
|
59
|
-
"leftTopToBottom": "rightTopToBottom",
|
|
60
|
-
"leftCenterToBottom": "rightCenterToBottom",
|
|
61
|
-
"leftCenter": "rightCenter",
|
|
62
|
-
"leftBottomToTop": "rightBottomToTop",
|
|
63
|
-
"leftCenterToTop": "rightCenterToTop",
|
|
64
|
-
"bottomRight": "bottomLeft",
|
|
65
|
-
"bottomLeft": "bottomRight",
|
|
66
|
-
"topRight": "topLeft",
|
|
67
|
-
"topLeft": "topRight",
|
|
68
|
-
"rightBottom": "leftBottom",
|
|
69
|
-
"rightTop": "leftTop",
|
|
70
|
-
"leftBottom": "rightBottom",
|
|
71
|
-
"leftTop": "rightTop"
|
|
72
|
-
};
|
package/es/Popup/Registry.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { getLibraryConfig } from "../Provider/Config.js";
|
|
2
|
-
const Registry = {
|
|
3
|
-
lastOpenedGroup: [],
|
|
4
|
-
popups: {},
|
|
5
|
-
listenerPopupRef: undefined,
|
|
6
|
-
scrollBlockedListenerPopupRef: undefined,
|
|
7
|
-
scrollableListenerPopupRef: undefined,
|
|
8
|
-
|
|
9
|
-
getOpenedPopups() {
|
|
10
|
-
return Object.values(Registry.popups).flat().filter(popup => popup.state.isPopupOpen);
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
-
getOpenedScrollBlockedFixedPopups() {
|
|
14
|
-
return Registry.getOpenedPopups().filter(popup => popup.getIsOutsideScrollBlocked(popup) && !popup.getIsAbsolutePopup(popup));
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
getOpenedScrollableFixedPopups() {
|
|
18
|
-
return Registry.getOpenedPopups().filter(popup => !popup.getIsOutsideScrollBlocked(popup) && !popup.getIsAbsolutePopup(popup));
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
getRootElement() {
|
|
22
|
-
const getRootElement = getLibraryConfig('getRootElement');
|
|
23
|
-
|
|
24
|
-
if (getRootElement && typeof getRootElement === 'function') {
|
|
25
|
-
const parent = getRootElement();
|
|
26
|
-
|
|
27
|
-
if (parent) {
|
|
28
|
-
return parent;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return document;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
};
|
|
36
|
-
export default Registry;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
let observerCallbacks = null;
|
|
2
|
-
let intersectionObserver = null;
|
|
3
|
-
|
|
4
|
-
function handleObserverCallbacks(entries) {
|
|
5
|
-
entries.forEach(entry => {
|
|
6
|
-
let oldCallbacks = observerCallbacks.get(entry.target);
|
|
7
|
-
|
|
8
|
-
if (Array.isArray(oldCallbacks) && oldCallbacks.length) {
|
|
9
|
-
oldCallbacks.forEach(callback => {
|
|
10
|
-
callback && callback(entry);
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function addIntersectionObserver(element, callback, options) {
|
|
17
|
-
if (!!element && typeof callback == 'function') {
|
|
18
|
-
if (intersectionObserver === null && observerCallbacks === null) {
|
|
19
|
-
intersectionObserver = new IntersectionObserver(entries => {
|
|
20
|
-
handleObserverCallbacks(entries);
|
|
21
|
-
}, options);
|
|
22
|
-
observerCallbacks = new Map();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
intersectionObserver.observe(element);
|
|
26
|
-
let oldCallbacks = observerCallbacks.get(element) || [];
|
|
27
|
-
observerCallbacks.set(element, [...oldCallbacks, callback]);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
export function removeIntersectionObserver(element, callback) {
|
|
31
|
-
if (!!element && typeof callback == 'function') {
|
|
32
|
-
let oldCallbacks = observerCallbacks ? observerCallbacks.get(element) : null;
|
|
33
|
-
|
|
34
|
-
if (Array.isArray(oldCallbacks)) {
|
|
35
|
-
let callbacks = oldCallbacks.filter(handler => handler !== callback);
|
|
36
|
-
|
|
37
|
-
if (intersectionObserver && callbacks.length === 0) {
|
|
38
|
-
observerCallbacks.delete(element);
|
|
39
|
-
intersectionObserver.unobserve(element);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (intersectionObserver && observerCallbacks && observerCallbacks.size === 0) {
|
|
44
|
-
intersectionObserver.disconnect();
|
|
45
|
-
intersectionObserver = null;
|
|
46
|
-
observerCallbacks = null;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|