SliderTooltip.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. compatConfig: {
  8. MODE: 3
  9. },
  10. name: 'SliderTooltip',
  11. inheritAttrs: false,
  12. props: tooltipProps(),
  13. setup: function setup(props, _ref) {
  14. var attrs = _ref.attrs,
  15. slots = _ref.slots;
  16. var innerRef = ref(null);
  17. var rafRef = ref(null);
  18. function cancelKeepAlign() {
  19. raf.cancel(rafRef.value);
  20. rafRef.value = null;
  21. }
  22. function keepAlign() {
  23. rafRef.value = raf(function () {
  24. var _innerRef$value;
  25. (_innerRef$value = innerRef.value) === null || _innerRef$value === void 0 ? void 0 : _innerRef$value.forcePopupAlign();
  26. rafRef.value = null;
  27. });
  28. }
  29. var align = function align() {
  30. cancelKeepAlign();
  31. if (props.visible) {
  32. keepAlign();
  33. }
  34. };
  35. watch([function () {
  36. return props.visible;
  37. }, function () {
  38. return props.title;
  39. }], function () {
  40. align();
  41. }, {
  42. flush: 'post',
  43. immediate: true
  44. });
  45. onActivated(function () {
  46. align();
  47. });
  48. onBeforeUnmount(function () {
  49. cancelKeepAlign();
  50. });
  51. return function () {
  52. return _createVNode(Tooltip, _objectSpread(_objectSpread({
  53. "ref": innerRef
  54. }, props), attrs), slots);
  55. };
  56. }
  57. });