@ultraviolet/ui 1.20.0 → 1.20.1
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.
|
@@ -153,7 +153,11 @@ const Popup = /*#__PURE__*/forwardRef((_ref13, ref) => {
|
|
|
153
153
|
}));
|
|
154
154
|
}
|
|
155
155
|
}, [innerTooltipRef, placement]);
|
|
156
|
-
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* This function is called when we need to recompute positions of tooltip due to window scroll or resize.
|
|
159
|
+
*/
|
|
160
|
+
const onWindowChangeDetected = useCallback(() => {
|
|
157
161
|
// We remove animation on scroll or the animation will restart on every scroll
|
|
158
162
|
if (innerTooltipRef.current) {
|
|
159
163
|
innerTooltipRef.current.style.animation = 'none';
|
|
@@ -167,8 +171,8 @@ const Popup = /*#__PURE__*/forwardRef((_ref13, ref) => {
|
|
|
167
171
|
const unmountTooltip = useCallback(() => {
|
|
168
172
|
setVisibleInDom(false);
|
|
169
173
|
setReverseAnimation(false);
|
|
170
|
-
window.removeEventListener('scroll',
|
|
171
|
-
}, [
|
|
174
|
+
window.removeEventListener('scroll', onWindowChangeDetected, true);
|
|
175
|
+
}, [onWindowChangeDetected]);
|
|
172
176
|
|
|
173
177
|
/**
|
|
174
178
|
* This function is called when we need to hide tooltip. A timeout is set to allow animation end, then remove
|
|
@@ -221,18 +225,20 @@ const Popup = /*#__PURE__*/forwardRef((_ref13, ref) => {
|
|
|
221
225
|
if (visibleInDom) {
|
|
222
226
|
generatePositions();
|
|
223
227
|
|
|
224
|
-
// We want to detect scroll in order to recompute positions of tooltip
|
|
228
|
+
// We want to detect scroll and resize in order to recompute positions of tooltip
|
|
225
229
|
// Adding true as third parameter to event listener will detect nested scrolls.
|
|
226
|
-
window.addEventListener('scroll',
|
|
230
|
+
window.addEventListener('scroll', onWindowChangeDetected, true);
|
|
231
|
+
window.addEventListener('resize', onWindowChangeDetected, true);
|
|
227
232
|
}
|
|
228
233
|
return () => {
|
|
229
|
-
window.removeEventListener('scroll',
|
|
234
|
+
window.removeEventListener('scroll', onWindowChangeDetected, true);
|
|
235
|
+
window.removeEventListener('resize', onWindowChangeDetected, true);
|
|
230
236
|
if (timer.current) {
|
|
231
237
|
clearTimeout(timer.current);
|
|
232
238
|
timer.current = undefined;
|
|
233
239
|
}
|
|
234
240
|
};
|
|
235
|
-
}, [generatePositions,
|
|
241
|
+
}, [generatePositions, onWindowChangeDetected, visibleInDom, maxWidth]);
|
|
236
242
|
|
|
237
243
|
/**
|
|
238
244
|
* If tooltip has `visible` prop it means the tooltip is manually controlled through this prop.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultraviolet/ui",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.1",
|
|
4
4
|
"description": "Ultraviolet UI",
|
|
5
5
|
"homepage": "https://github.com/scaleway/ultraviolet#readme",
|
|
6
6
|
"repository": {
|
|
@@ -68,5 +68,8 @@
|
|
|
68
68
|
"reakit": "1.3.11",
|
|
69
69
|
"@ultraviolet/themes": "1.2.1",
|
|
70
70
|
"@ultraviolet/icons": "2.4.1"
|
|
71
|
+
},
|
|
72
|
+
"scripts": {
|
|
73
|
+
"build": "rollup -c ../../rollup.config.mjs"
|
|
71
74
|
}
|
|
72
75
|
}
|