SliderTooltip.js
1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var React = _interopRequireWildcard(require("react"));
var _ref = require("rc-util/lib/ref");
var _raf = _interopRequireDefault(require("rc-util/lib/raf"));
var _tooltip = _interopRequireDefault(require("../tooltip"));
var SliderTooltip = /*#__PURE__*/React.forwardRef(function (props, ref) {
var visible = props.visible;
var innerRef = (0, React.useRef)(null);
var rafRef = (0, React.useRef)(null);
function cancelKeepAlign() {
_raf["default"].cancel(rafRef.current);
rafRef.current = null;
}
function keepAlign() {
rafRef.current = (0, _raf["default"])(function () {
innerRef.current.forcePopupAlign();
rafRef.current = null;
keepAlign();
});
}
React.useEffect(function () {
if (visible) {
keepAlign();
} else {
cancelKeepAlign();
}
return cancelKeepAlign;
}, [visible]);
return /*#__PURE__*/React.createElement(_tooltip["default"], (0, _extends2["default"])({
ref: (0, _ref.composeRef)(innerRef, ref)
}, props));
});
var _default = SliderTooltip;
exports["default"] = _default;