1 | import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
2 | import { createVNode as _createVNode, resolveDirective as _resolveDirective } from "vue";
|
3 | import { onBeforeUnmount, watch, onActivated, defineComponent, ref } from 'vue';
|
4 | import Tooltip, { tooltipProps } from '../tooltip';
|
5 | import raf from '../_util/raf';
|
6 | export default defineComponent({
|
7 | name: 'SliderTooltip',
|
8 | inheritAttrs: false,
|
9 | props: tooltipProps(),
|
10 | setup: function setup(props, _ref) {
|
11 | var attrs = _ref.attrs,
|
12 | slots = _ref.slots;
|
13 | var innerRef = ref(null);
|
14 | var rafRef = ref(null);
|
15 |
|
16 | function cancelKeepAlign() {
|
17 | raf.cancel(rafRef.value);
|
18 | rafRef.value = null;
|
19 | }
|
20 |
|
21 | function keepAlign() {
|
22 | rafRef.value = raf(function () {
|
23 | var _a;
|
24 |
|
25 | (_a = innerRef.value) === null || _a === void 0 ? void 0 : _a.forcePopupAlign();
|
26 | rafRef.value = null;
|
27 | });
|
28 | }
|
29 |
|
30 | var align = function align() {
|
31 | cancelKeepAlign();
|
32 |
|
33 | if (props.visible) {
|
34 | keepAlign();
|
35 | }
|
36 | };
|
37 |
|
38 | watch([function () {
|
39 | return props.visible;
|
40 | }, function () {
|
41 | return props.title;
|
42 | }], function () {
|
43 | align();
|
44 | }, {
|
45 | flush: 'post',
|
46 | immediate: true
|
47 | });
|
48 | onActivated(function () {
|
49 | align();
|
50 | });
|
51 | onBeforeUnmount(function () {
|
52 | cancelKeepAlign();
|
53 | });
|
54 | return function () {
|
55 | return _createVNode(Tooltip, _objectSpread(_objectSpread({
|
56 | "ref": innerRef
|
57 | }, props), attrs), slots);
|
58 | };
|
59 | }
|
60 | }); |
\ | No newline at end of file |