@zohodesk/components 1.2.46 → 1.2.48
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 +13 -0
- package/es/DateTime/CalendarView.js +9 -7
- package/es/Responsive/ResizeObserver.js +21 -85
- package/es/Responsive/ResizeObserverWithPolyfill.js +140 -0
- package/lib/DateTime/CalendarView.js +9 -7
- package/lib/Responsive/ResizeObserver.js +20 -88
- package/lib/Responsive/ResizeObserverWithPolyfill.js +168 -0
- package/package.json +5 -5
- package/result.json +1 -1
package/README.md
CHANGED
|
@@ -32,6 +32,19 @@ In this Package, we Provide Some Basic Components to Build Web App
|
|
|
32
32
|
- TextBoxIcon
|
|
33
33
|
- Tooltip
|
|
34
34
|
|
|
35
|
+
# 1.2.48
|
|
36
|
+
|
|
37
|
+
- **ResizeObserver**
|
|
38
|
+
|
|
39
|
+
- The ResizeObserver PolyFill code has been removed, and a separate copy with the PolyFill included is saved under the filename ResizeObserverWithPolyfill.js
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# 1.2.47
|
|
43
|
+
|
|
44
|
+
- **DateTime**
|
|
45
|
+
|
|
46
|
+
- The issue of the dateTime_dateSelected string being duplicated in the data_id attribute when selecting the last day of the month has been resolved.
|
|
47
|
+
|
|
35
48
|
# 1.2.46
|
|
36
49
|
|
|
37
50
|
- **AppContainer (v1)**
|
|
@@ -62,6 +62,7 @@ export default class CalendarView extends React.PureComponent {
|
|
|
62
62
|
let output = null;
|
|
63
63
|
|
|
64
64
|
for (let i = 1; i < 8; i++) {
|
|
65
|
+
isSelectedDay = false;
|
|
65
66
|
let tdclass = `${style.datesStr} ${style.grid}`;
|
|
66
67
|
|
|
67
68
|
if (i === 1) {
|
|
@@ -102,8 +103,8 @@ export default class CalendarView extends React.PureComponent {
|
|
|
102
103
|
|
|
103
104
|
const prevMonthEnd = getMonthEnd(prevMonth, prevYear);
|
|
104
105
|
const prevDate = prevMonthEnd - (userSeeDay - 1) + incremleti; // isSelectedDay =
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
// prevDate === parseInt(date) && parseInt(month) === prevMonth && parseInt(year) === prevYear ? true : false;
|
|
107
|
+
// isToday = prevDate === incremday && todayMonth === userSeeMonth && todayYear === userSeeYear ? true : false;
|
|
107
108
|
|
|
108
109
|
output = /*#__PURE__*/React.createElement(Span, {
|
|
109
110
|
i: i //isActive={isSelectedDay}
|
|
@@ -113,7 +114,7 @@ export default class CalendarView extends React.PureComponent {
|
|
|
113
114
|
incremday: prevDate,
|
|
114
115
|
userSeeMonth: prevMonth,
|
|
115
116
|
userSeeYear: prevYear,
|
|
116
|
-
dataId:
|
|
117
|
+
dataId: `${dataId}_invalidDate` // isToday={isToday}
|
|
117
118
|
|
|
118
119
|
});
|
|
119
120
|
} else if (incremleti > monthEnd) {
|
|
@@ -125,9 +126,10 @@ export default class CalendarView extends React.PureComponent {
|
|
|
125
126
|
nextYear = userSeeYear + 1;
|
|
126
127
|
}
|
|
127
128
|
|
|
128
|
-
const nextDate = incremleti - (userSeeDay - 1) - monthEnd; //
|
|
129
|
-
|
|
130
|
-
nextDate === parseInt(date) && parseInt(month) === nextMonth && parseInt(year) === nextYear ? true : false;
|
|
129
|
+
const nextDate = incremleti - (userSeeDay - 1) - monthEnd; // console.log('last dates',incremleti, monthEnd,'nextDate',nextDate,'monthEnd',monthEnd,'userSeeDay',userSeeDay)
|
|
130
|
+
// isSelectedDay =
|
|
131
|
+
// nextDate === parseInt(date) && parseInt(month) === nextMonth && parseInt(year) === nextYear ? true : false;
|
|
132
|
+
// isToday = nextDate === incremday && todayMonth === userSeeMonth && todayYear === userSeeYear ? true : false;
|
|
131
133
|
|
|
132
134
|
output = /*#__PURE__*/React.createElement(Span, {
|
|
133
135
|
i: i // isActive={isSelectedDay}
|
|
@@ -137,7 +139,7 @@ export default class CalendarView extends React.PureComponent {
|
|
|
137
139
|
incremday: nextDate,
|
|
138
140
|
userSeeMonth: nextMonth,
|
|
139
141
|
userSeeYear: nextYear,
|
|
140
|
-
dataId:
|
|
142
|
+
dataId: `${dataId}_invalidDate` //isToday={isToday}
|
|
141
143
|
|
|
142
144
|
});
|
|
143
145
|
} else {
|
|
@@ -1,68 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
function getSize(element) {
|
|
9
|
-
let {
|
|
10
|
-
offsetHeight,
|
|
11
|
-
offsetWidth
|
|
12
|
-
} = element; // const { height, width } = element.getBoundingClientRect();
|
|
1
|
+
function getBorderBoxSizeFromEntry(entry) {
|
|
2
|
+
const {
|
|
3
|
+
borderBoxSize
|
|
4
|
+
} = entry;
|
|
5
|
+
return borderBoxSize[0];
|
|
6
|
+
}
|
|
13
7
|
|
|
8
|
+
function getSize(entry) {
|
|
9
|
+
const borderBoxSize = getBorderBoxSizeFromEntry(entry);
|
|
14
10
|
return {
|
|
15
|
-
height:
|
|
16
|
-
width:
|
|
11
|
+
height: borderBoxSize.blockSize,
|
|
12
|
+
width: borderBoxSize.inlineSize
|
|
17
13
|
};
|
|
18
14
|
}
|
|
19
15
|
|
|
20
|
-
function dispatch() {
|
|
21
|
-
let resizeResponsive = new Event('resizeResponsive');
|
|
22
|
-
window.dispatchEvent(resizeResponsive);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (!hasResizeObserver) {
|
|
26
|
-
let interval = null;
|
|
27
|
-
window.addEventListener('resize', () => {
|
|
28
|
-
clearTimeout(interval);
|
|
29
|
-
interval = setTimeout(dispatch, 100);
|
|
30
|
-
});
|
|
31
|
-
} // NOTE: this is not full polyfill , we just wrote what types of changes wlli
|
|
32
|
-
|
|
33
|
-
|
|
34
16
|
export default class ResizeObserverPolyfill {
|
|
35
17
|
constructor(onResize) {
|
|
36
|
-
// method finding
|
|
37
|
-
this.transitionEndHandler = this.transitionEndHandler.bind(this);
|
|
38
|
-
this.resizeHandlerDispatch = this.resizeHandlerDispatch.bind(this);
|
|
39
18
|
this.resizeHandler = this.resizeHandler.bind(this);
|
|
40
|
-
this.replaceResizeHandler = this.replaceResizeHandler.bind(this);
|
|
41
|
-
this.debounce = this.debounce.bind(this);
|
|
42
19
|
this.onResize = onResize;
|
|
43
20
|
this.targetNode = null;
|
|
44
21
|
this.size = {
|
|
45
22
|
height: 0,
|
|
46
23
|
width: 0
|
|
47
24
|
};
|
|
48
|
-
|
|
49
|
-
if (hasResizeObserver) {
|
|
50
|
-
this.resizeObserverInstance = new window.ResizeObserver(this.resizeHandlerDispatch);
|
|
51
|
-
} else {
|
|
52
|
-
this.mutationObserverInstance = new window.MutationObserver(this.resizeHandlerDispatch);
|
|
53
|
-
}
|
|
25
|
+
this.resizeObserverInstance = new window.ResizeObserver(this.resizeHandler);
|
|
54
26
|
}
|
|
55
27
|
|
|
56
28
|
replaceResizeHandler(onResize) {
|
|
57
29
|
this.onResize = onResize;
|
|
58
30
|
}
|
|
59
31
|
|
|
60
|
-
|
|
61
|
-
|
|
32
|
+
getEntry(entries) {
|
|
33
|
+
return entries[0];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
resizeHandler(entries) {
|
|
37
|
+
if (!this.targetNode || !entries.length) {
|
|
62
38
|
return;
|
|
63
39
|
}
|
|
64
40
|
|
|
65
|
-
const
|
|
41
|
+
const entry = this.getEntry(entries);
|
|
42
|
+
const currentSize = getSize(entry);
|
|
66
43
|
|
|
67
44
|
if (this.size && currentSize.height === this.size.height && currentSize.width === this.size.width) {
|
|
68
45
|
return;
|
|
@@ -73,48 +50,9 @@ export default class ResizeObserverPolyfill {
|
|
|
73
50
|
return true;
|
|
74
51
|
}
|
|
75
52
|
|
|
76
|
-
resizeHandlerDispatch() {
|
|
77
|
-
if (!this.resizeHandler() || hasResizeObserver) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
dispatch();
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
debounce() {
|
|
85
|
-
clearTimeout(this.interval);
|
|
86
|
-
this.interval = setTimeout(this.resizeHandler, 100);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
transitionEndHandler(event) {
|
|
90
|
-
if (event.propertyName.indexOf('color') === -1) {
|
|
91
|
-
this.resizeHandlerDispatch();
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
addEventListeners(targetNode) {
|
|
96
|
-
targetNode.addEventListener('transitionend', this.transitionEndHandler);
|
|
97
|
-
window.addEventListener('resizeResponsive', this.debounce);
|
|
98
|
-
targetNode.addEventListener('animationend', this.resizeHandlerDispatch);
|
|
99
|
-
targetNode.addEventListener('webkitAnimationEnd', this.resizeHandlerDispatch);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
removeEventListeners(targetNode) {
|
|
103
|
-
targetNode.removeEventListener('transitionend', this.transitionEndHandler);
|
|
104
|
-
window.removeEventListener('resizeResponsive', this.debounce);
|
|
105
|
-
targetNode.removeEventListener('animationend', this.resizeHandlerDispatch);
|
|
106
|
-
targetNode.removeEventListener('webkitAnimationEnd', this.resizeHandlerDispatch);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
53
|
observe(targetNode) {
|
|
110
54
|
this.targetNode = targetNode;
|
|
111
|
-
|
|
112
|
-
if (hasResizeObserver) {
|
|
113
|
-
this.resizeObserverInstance.observe(targetNode);
|
|
114
|
-
} else {
|
|
115
|
-
this.addEventListeners(targetNode);
|
|
116
|
-
this.mutationObserverInstance.observe(targetNode, mutationObserverOptions);
|
|
117
|
-
}
|
|
55
|
+
this.resizeObserverInstance.observe(targetNode);
|
|
118
56
|
}
|
|
119
57
|
|
|
120
58
|
replaceObservationElement(targetNode) {
|
|
@@ -124,12 +62,10 @@ export default class ResizeObserverPolyfill {
|
|
|
124
62
|
|
|
125
63
|
this.targetNode && this.disconnect();
|
|
126
64
|
targetNode && this.observe(targetNode);
|
|
127
|
-
targetNode && this.resizeHandlerDispatch();
|
|
128
65
|
}
|
|
129
66
|
|
|
130
67
|
disconnect() {
|
|
131
|
-
this.
|
|
132
|
-
hasResizeObserver ? this.resizeObserverInstance.disconnect() : this.mutationObserverInstance.disconnect();
|
|
68
|
+
this.resizeObserverInstance.disconnect();
|
|
133
69
|
this.targetNode = null;
|
|
134
70
|
this.size = {
|
|
135
71
|
height: 0,
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
const hasResizeObserver = !!window.ResizeObserver;
|
|
2
|
+
const mutationObserverOptions = {
|
|
3
|
+
//NOTE: we donot consider child Count
|
|
4
|
+
// childList: true,
|
|
5
|
+
attributes: true
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
function getSize(element) {
|
|
9
|
+
let {
|
|
10
|
+
offsetHeight,
|
|
11
|
+
offsetWidth
|
|
12
|
+
} = element; // const { height, width } = element.getBoundingClientRect();
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
height: offsetHeight,
|
|
16
|
+
width: offsetWidth
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function dispatch() {
|
|
21
|
+
let resizeResponsive = new Event('resizeResponsive');
|
|
22
|
+
window.dispatchEvent(resizeResponsive);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (!hasResizeObserver) {
|
|
26
|
+
let interval = null;
|
|
27
|
+
window.addEventListener('resize', () => {
|
|
28
|
+
clearTimeout(interval);
|
|
29
|
+
interval = setTimeout(dispatch, 100);
|
|
30
|
+
});
|
|
31
|
+
} // NOTE: this is not full polyfill , we just wrote what types of changes wlli
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
export default class ResizeObserverPolyfill {
|
|
35
|
+
constructor(onResize) {
|
|
36
|
+
// method finding
|
|
37
|
+
this.transitionEndHandler = this.transitionEndHandler.bind(this);
|
|
38
|
+
this.resizeHandlerDispatch = this.resizeHandlerDispatch.bind(this);
|
|
39
|
+
this.resizeHandler = this.resizeHandler.bind(this);
|
|
40
|
+
this.replaceResizeHandler = this.replaceResizeHandler.bind(this);
|
|
41
|
+
this.debounce = this.debounce.bind(this);
|
|
42
|
+
this.onResize = onResize;
|
|
43
|
+
this.targetNode = null;
|
|
44
|
+
this.size = {
|
|
45
|
+
height: 0,
|
|
46
|
+
width: 0
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
if (hasResizeObserver) {
|
|
50
|
+
this.resizeObserverInstance = new window.ResizeObserver(this.resizeHandlerDispatch);
|
|
51
|
+
} else {
|
|
52
|
+
this.mutationObserverInstance = new window.MutationObserver(this.resizeHandlerDispatch);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
replaceResizeHandler(onResize) {
|
|
57
|
+
this.onResize = onResize;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
resizeHandler() {
|
|
61
|
+
if (!this.targetNode) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const currentSize = getSize(this.targetNode); // if (this.size && shallowCompare(currentSize, this.size)) {
|
|
66
|
+
|
|
67
|
+
if (this.size && currentSize.height === this.size.height && currentSize.width === this.size.width) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
this.size = currentSize;
|
|
72
|
+
this.onResize(this.size, this.targetNode);
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
resizeHandlerDispatch() {
|
|
77
|
+
if (!this.resizeHandler() || hasResizeObserver) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
dispatch();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
debounce() {
|
|
85
|
+
clearTimeout(this.interval);
|
|
86
|
+
this.interval = setTimeout(this.resizeHandler, 100);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
transitionEndHandler(event) {
|
|
90
|
+
if (event.propertyName.indexOf('color') === -1) {
|
|
91
|
+
this.resizeHandlerDispatch();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
addEventListeners(targetNode) {
|
|
96
|
+
targetNode.addEventListener('transitionend', this.transitionEndHandler);
|
|
97
|
+
window.addEventListener('resizeResponsive', this.debounce);
|
|
98
|
+
targetNode.addEventListener('animationend', this.resizeHandlerDispatch);
|
|
99
|
+
targetNode.addEventListener('webkitAnimationEnd', this.resizeHandlerDispatch);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
removeEventListeners(targetNode) {
|
|
103
|
+
targetNode.removeEventListener('transitionend', this.transitionEndHandler);
|
|
104
|
+
window.removeEventListener('resizeResponsive', this.debounce);
|
|
105
|
+
targetNode.removeEventListener('animationend', this.resizeHandlerDispatch);
|
|
106
|
+
targetNode.removeEventListener('webkitAnimationEnd', this.resizeHandlerDispatch);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
observe(targetNode) {
|
|
110
|
+
this.targetNode = targetNode;
|
|
111
|
+
|
|
112
|
+
if (hasResizeObserver) {
|
|
113
|
+
this.resizeObserverInstance.observe(targetNode);
|
|
114
|
+
} else {
|
|
115
|
+
this.addEventListeners(targetNode);
|
|
116
|
+
this.mutationObserverInstance.observe(targetNode, mutationObserverOptions);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
replaceObservationElement(targetNode) {
|
|
121
|
+
if (this.targetNode === targetNode) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
this.targetNode && this.disconnect();
|
|
126
|
+
targetNode && this.observe(targetNode);
|
|
127
|
+
targetNode && this.resizeHandlerDispatch();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
disconnect() {
|
|
131
|
+
this.targetNode && this.removeEventListeners(this.targetNode);
|
|
132
|
+
hasResizeObserver ? this.resizeObserverInstance.disconnect() : this.mutationObserverInstance.disconnect();
|
|
133
|
+
this.targetNode = null;
|
|
134
|
+
this.size = {
|
|
135
|
+
height: 0,
|
|
136
|
+
width: 0
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
}
|
|
@@ -110,6 +110,7 @@ var CalendarView = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
110
110
|
var output = null;
|
|
111
111
|
|
|
112
112
|
for (var i = 1; i < 8; i++) {
|
|
113
|
+
isSelectedDay = false;
|
|
113
114
|
var tdclass = "".concat(_DateTimeModule["default"].datesStr, " ").concat(_DateTimeModule["default"].grid);
|
|
114
115
|
|
|
115
116
|
if (i === 1) {
|
|
@@ -150,8 +151,8 @@ var CalendarView = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
150
151
|
|
|
151
152
|
var prevMonthEnd = (0, _common.getMonthEnd)(prevMonth, prevYear);
|
|
152
153
|
var prevDate = prevMonthEnd - (userSeeDay - 1) + incremleti; // isSelectedDay =
|
|
153
|
-
|
|
154
|
-
|
|
154
|
+
// prevDate === parseInt(date) && parseInt(month) === prevMonth && parseInt(year) === prevYear ? true : false;
|
|
155
|
+
// isToday = prevDate === incremday && todayMonth === userSeeMonth && todayYear === userSeeYear ? true : false;
|
|
155
156
|
|
|
156
157
|
output = /*#__PURE__*/_react["default"].createElement(Span, {
|
|
157
158
|
i: i //isActive={isSelectedDay}
|
|
@@ -161,7 +162,7 @@ var CalendarView = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
161
162
|
incremday: prevDate,
|
|
162
163
|
userSeeMonth: prevMonth,
|
|
163
164
|
userSeeYear: prevYear,
|
|
164
|
-
dataId:
|
|
165
|
+
dataId: "".concat(dataId, "_invalidDate") // isToday={isToday}
|
|
165
166
|
|
|
166
167
|
});
|
|
167
168
|
} else if (incremleti > monthEnd) {
|
|
@@ -173,9 +174,10 @@ var CalendarView = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
173
174
|
nextYear = userSeeYear + 1;
|
|
174
175
|
}
|
|
175
176
|
|
|
176
|
-
var nextDate = incremleti - (userSeeDay - 1) - monthEnd; //
|
|
177
|
-
|
|
178
|
-
nextDate === parseInt(date) && parseInt(month) === nextMonth && parseInt(year) === nextYear ? true : false;
|
|
177
|
+
var nextDate = incremleti - (userSeeDay - 1) - monthEnd; // console.log('last dates',incremleti, monthEnd,'nextDate',nextDate,'monthEnd',monthEnd,'userSeeDay',userSeeDay)
|
|
178
|
+
// isSelectedDay =
|
|
179
|
+
// nextDate === parseInt(date) && parseInt(month) === nextMonth && parseInt(year) === nextYear ? true : false;
|
|
180
|
+
// isToday = nextDate === incremday && todayMonth === userSeeMonth && todayYear === userSeeYear ? true : false;
|
|
179
181
|
|
|
180
182
|
output = /*#__PURE__*/_react["default"].createElement(Span, {
|
|
181
183
|
i: i // isActive={isSelectedDay}
|
|
@@ -185,7 +187,7 @@ var CalendarView = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
185
187
|
incremday: nextDate,
|
|
186
188
|
userSeeMonth: nextMonth,
|
|
187
189
|
userSeeYear: nextYear,
|
|
188
|
-
dataId:
|
|
190
|
+
dataId: "".concat(dataId, "_invalidDate") //isToday={isToday}
|
|
189
191
|
|
|
190
192
|
});
|
|
191
193
|
} else {
|
|
@@ -11,59 +11,31 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
11
11
|
|
|
12
12
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
attributes: true
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
function getSize(element) {
|
|
22
|
-
var offsetHeight = element.offsetHeight,
|
|
23
|
-
offsetWidth = element.offsetWidth; // const { height, width } = element.getBoundingClientRect();
|
|
14
|
+
function getBorderBoxSizeFromEntry(entry) {
|
|
15
|
+
var borderBoxSize = entry.borderBoxSize;
|
|
16
|
+
return borderBoxSize[0];
|
|
17
|
+
}
|
|
24
18
|
|
|
19
|
+
function getSize(entry) {
|
|
20
|
+
var borderBoxSize = getBorderBoxSizeFromEntry(entry);
|
|
25
21
|
return {
|
|
26
|
-
height:
|
|
27
|
-
width:
|
|
22
|
+
height: borderBoxSize.blockSize,
|
|
23
|
+
width: borderBoxSize.inlineSize
|
|
28
24
|
};
|
|
29
25
|
}
|
|
30
26
|
|
|
31
|
-
function dispatch() {
|
|
32
|
-
var resizeResponsive = new Event('resizeResponsive');
|
|
33
|
-
window.dispatchEvent(resizeResponsive);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (!hasResizeObserver) {
|
|
37
|
-
var interval = null;
|
|
38
|
-
window.addEventListener('resize', function () {
|
|
39
|
-
clearTimeout(interval);
|
|
40
|
-
interval = setTimeout(dispatch, 100);
|
|
41
|
-
});
|
|
42
|
-
} // NOTE: this is not full polyfill , we just wrote what types of changes wlli
|
|
43
|
-
|
|
44
|
-
|
|
45
27
|
var ResizeObserverPolyfill = /*#__PURE__*/function () {
|
|
46
28
|
function ResizeObserverPolyfill(onResize) {
|
|
47
29
|
_classCallCheck(this, ResizeObserverPolyfill);
|
|
48
30
|
|
|
49
|
-
// method finding
|
|
50
|
-
this.transitionEndHandler = this.transitionEndHandler.bind(this);
|
|
51
|
-
this.resizeHandlerDispatch = this.resizeHandlerDispatch.bind(this);
|
|
52
31
|
this.resizeHandler = this.resizeHandler.bind(this);
|
|
53
|
-
this.replaceResizeHandler = this.replaceResizeHandler.bind(this);
|
|
54
|
-
this.debounce = this.debounce.bind(this);
|
|
55
32
|
this.onResize = onResize;
|
|
56
33
|
this.targetNode = null;
|
|
57
34
|
this.size = {
|
|
58
35
|
height: 0,
|
|
59
36
|
width: 0
|
|
60
37
|
};
|
|
61
|
-
|
|
62
|
-
if (hasResizeObserver) {
|
|
63
|
-
this.resizeObserverInstance = new window.ResizeObserver(this.resizeHandlerDispatch);
|
|
64
|
-
} else {
|
|
65
|
-
this.mutationObserverInstance = new window.MutationObserver(this.resizeHandlerDispatch);
|
|
66
|
-
}
|
|
38
|
+
this.resizeObserverInstance = new window.ResizeObserver(this.resizeHandler);
|
|
67
39
|
}
|
|
68
40
|
|
|
69
41
|
_createClass(ResizeObserverPolyfill, [{
|
|
@@ -71,14 +43,20 @@ var ResizeObserverPolyfill = /*#__PURE__*/function () {
|
|
|
71
43
|
value: function replaceResizeHandler(onResize) {
|
|
72
44
|
this.onResize = onResize;
|
|
73
45
|
}
|
|
46
|
+
}, {
|
|
47
|
+
key: "getEntry",
|
|
48
|
+
value: function getEntry(entries) {
|
|
49
|
+
return entries[0];
|
|
50
|
+
}
|
|
74
51
|
}, {
|
|
75
52
|
key: "resizeHandler",
|
|
76
|
-
value: function resizeHandler() {
|
|
77
|
-
if (!this.targetNode) {
|
|
53
|
+
value: function resizeHandler(entries) {
|
|
54
|
+
if (!this.targetNode || !entries.length) {
|
|
78
55
|
return;
|
|
79
56
|
}
|
|
80
57
|
|
|
81
|
-
var
|
|
58
|
+
var entry = this.getEntry(entries);
|
|
59
|
+
var currentSize = getSize(entry);
|
|
82
60
|
|
|
83
61
|
if (this.size && currentSize.height === this.size.height && currentSize.width === this.size.width) {
|
|
84
62
|
return;
|
|
@@ -88,55 +66,11 @@ var ResizeObserverPolyfill = /*#__PURE__*/function () {
|
|
|
88
66
|
this.onResize(this.size, this.targetNode);
|
|
89
67
|
return true;
|
|
90
68
|
}
|
|
91
|
-
}, {
|
|
92
|
-
key: "resizeHandlerDispatch",
|
|
93
|
-
value: function resizeHandlerDispatch() {
|
|
94
|
-
if (!this.resizeHandler() || hasResizeObserver) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
dispatch();
|
|
99
|
-
}
|
|
100
|
-
}, {
|
|
101
|
-
key: "debounce",
|
|
102
|
-
value: function debounce() {
|
|
103
|
-
clearTimeout(this.interval);
|
|
104
|
-
this.interval = setTimeout(this.resizeHandler, 100);
|
|
105
|
-
}
|
|
106
|
-
}, {
|
|
107
|
-
key: "transitionEndHandler",
|
|
108
|
-
value: function transitionEndHandler(event) {
|
|
109
|
-
if (event.propertyName.indexOf('color') === -1) {
|
|
110
|
-
this.resizeHandlerDispatch();
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}, {
|
|
114
|
-
key: "addEventListeners",
|
|
115
|
-
value: function addEventListeners(targetNode) {
|
|
116
|
-
targetNode.addEventListener('transitionend', this.transitionEndHandler);
|
|
117
|
-
window.addEventListener('resizeResponsive', this.debounce);
|
|
118
|
-
targetNode.addEventListener('animationend', this.resizeHandlerDispatch);
|
|
119
|
-
targetNode.addEventListener('webkitAnimationEnd', this.resizeHandlerDispatch);
|
|
120
|
-
}
|
|
121
|
-
}, {
|
|
122
|
-
key: "removeEventListeners",
|
|
123
|
-
value: function removeEventListeners(targetNode) {
|
|
124
|
-
targetNode.removeEventListener('transitionend', this.transitionEndHandler);
|
|
125
|
-
window.removeEventListener('resizeResponsive', this.debounce);
|
|
126
|
-
targetNode.removeEventListener('animationend', this.resizeHandlerDispatch);
|
|
127
|
-
targetNode.removeEventListener('webkitAnimationEnd', this.resizeHandlerDispatch);
|
|
128
|
-
}
|
|
129
69
|
}, {
|
|
130
70
|
key: "observe",
|
|
131
71
|
value: function observe(targetNode) {
|
|
132
72
|
this.targetNode = targetNode;
|
|
133
|
-
|
|
134
|
-
if (hasResizeObserver) {
|
|
135
|
-
this.resizeObserverInstance.observe(targetNode);
|
|
136
|
-
} else {
|
|
137
|
-
this.addEventListeners(targetNode);
|
|
138
|
-
this.mutationObserverInstance.observe(targetNode, mutationObserverOptions);
|
|
139
|
-
}
|
|
73
|
+
this.resizeObserverInstance.observe(targetNode);
|
|
140
74
|
}
|
|
141
75
|
}, {
|
|
142
76
|
key: "replaceObservationElement",
|
|
@@ -147,13 +81,11 @@ var ResizeObserverPolyfill = /*#__PURE__*/function () {
|
|
|
147
81
|
|
|
148
82
|
this.targetNode && this.disconnect();
|
|
149
83
|
targetNode && this.observe(targetNode);
|
|
150
|
-
targetNode && this.resizeHandlerDispatch();
|
|
151
84
|
}
|
|
152
85
|
}, {
|
|
153
86
|
key: "disconnect",
|
|
154
87
|
value: function disconnect() {
|
|
155
|
-
this.
|
|
156
|
-
hasResizeObserver ? this.resizeObserverInstance.disconnect() : this.mutationObserverInstance.disconnect();
|
|
88
|
+
this.resizeObserverInstance.disconnect();
|
|
157
89
|
this.targetNode = null;
|
|
158
90
|
this.size = {
|
|
159
91
|
height: 0,
|