linkmore-design
Version:
π πlmη»δ»ΆεΊγπ
34 lines β’ 1.07 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import raf from 'rc-util/lib/raf';
import { composeRef } from 'rc-util/lib/ref';
import * as React from 'react';
import { useRef } from 'react';
import Tooltip from "../tooltip";
var SliderTooltip = /*#__PURE__*/React.forwardRef(function (props, ref) {
var open = props.open;
var innerRef = useRef(null);
var rafRef = useRef(null);
function cancelKeepAlign() {
raf.cancel(rafRef.current);
rafRef.current = null;
}
function keepAlign() {
rafRef.current = raf(function () {
var _innerRef$current;
(_innerRef$current = innerRef.current) === null || _innerRef$current === void 0 ? void 0 : _innerRef$current.forcePopupAlign();
rafRef.current = null;
});
}
React.useEffect(function () {
if (open) {
keepAlign();
} else {
cancelKeepAlign();
}
return cancelKeepAlign;
}, [open, props.title]);
return /*#__PURE__*/React.createElement(Tooltip, _extends({
ref: composeRef(innerRef, ref)
}, props));
});
export default SliderTooltip;