UNPKG

ant-design-vue

Version:

An enterprise-class UI design language and Vue-based implementation

60 lines (54 loc) 1.5 kB
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2"; import { createVNode as _createVNode, resolveDirective as _resolveDirective } from "vue"; import { onBeforeUnmount, watch, onActivated, defineComponent, ref } from 'vue'; import Tooltip, { tooltipProps } from '../tooltip'; import raf from '../_util/raf'; export default defineComponent({ name: 'SliderTooltip', inheritAttrs: false, props: tooltipProps(), setup: function setup(props, _ref) { var attrs = _ref.attrs, slots = _ref.slots; var innerRef = ref(null); var rafRef = ref(null); function cancelKeepAlign() { raf.cancel(rafRef.value); rafRef.value = null; } function keepAlign() { rafRef.value = raf(function () { var _a; (_a = innerRef.value) === null || _a === void 0 ? void 0 : _a.forcePopupAlign(); rafRef.value = null; }); } var align = function align() { cancelKeepAlign(); if (props.visible) { keepAlign(); } }; watch([function () { return props.visible; }, function () { return props.title; }], function () { align(); }, { flush: 'post', immediate: true }); onActivated(function () { align(); }); onBeforeUnmount(function () { cancelKeepAlign(); }); return function () { return _createVNode(Tooltip, _objectSpread(_objectSpread({ "ref": innerRef }, props), attrs), slots); }; } });