1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | import raf from "rc-util/es/raf";
|
3 | import { composeRef } from "rc-util/es/ref";
|
4 | import * as React from 'react';
|
5 | import { useRef } from 'react';
|
6 | import Tooltip from '../tooltip';
|
7 | var SliderTooltip = React.forwardRef(function (props, ref) {
|
8 | var open = props.open;
|
9 | var innerRef = useRef(null);
|
10 | var rafRef = useRef(null);
|
11 | function cancelKeepAlign() {
|
12 | raf.cancel(rafRef.current);
|
13 | rafRef.current = null;
|
14 | }
|
15 | function keepAlign() {
|
16 | rafRef.current = raf(function () {
|
17 | var _a;
|
18 | (_a = innerRef.current) === null || _a === void 0 ? void 0 : _a.forcePopupAlign();
|
19 | rafRef.current = null;
|
20 | });
|
21 | }
|
22 | React.useEffect(function () {
|
23 | if (open) {
|
24 | keepAlign();
|
25 | } else {
|
26 | cancelKeepAlign();
|
27 | }
|
28 | return cancelKeepAlign;
|
29 | }, [open, props.title]);
|
30 | return React.createElement(Tooltip, _extends({
|
31 | ref: composeRef(innerRef, ref)
|
32 | }, props));
|
33 | });
|
34 | export default SliderTooltip; |
\ | No newline at end of file |