mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-02 12:07:54 +08:00
a2f7d6d062
closes vueComponent/ant-design-vue#5765 Add `compatConfig: { MODE: 3 }` to all component definitions to signal to `@vue/compat` not to use any Vue 2 compatibility features.
50 lines
1.1 KiB
Vue
50 lines
1.1 KiB
Vue
import { onBeforeUnmount, watch, onActivated, defineComponent, ref } from 'vue';
|
|
import Tooltip, { tooltipProps } from '../tooltip';
|
|
import raf from '../_util/raf';
|
|
|
|
export default defineComponent({
|
|
compatConfig: { MODE: 3 },
|
|
name: 'SliderTooltip',
|
|
inheritAttrs: false,
|
|
props: tooltipProps(),
|
|
setup(props, { attrs, slots }) {
|
|
const innerRef = ref<any>(null);
|
|
|
|
const rafRef = ref<number>(null);
|
|
|
|
function cancelKeepAlign() {
|
|
raf.cancel(rafRef.value!);
|
|
rafRef.value = null;
|
|
}
|
|
|
|
function keepAlign() {
|
|
rafRef.value = raf(() => {
|
|
innerRef.value?.forcePopupAlign();
|
|
rafRef.value = null;
|
|
});
|
|
}
|
|
const align = () => {
|
|
cancelKeepAlign();
|
|
if (props.visible) {
|
|
keepAlign();
|
|
}
|
|
};
|
|
watch(
|
|
[() => props.visible, () => props.title],
|
|
() => {
|
|
align();
|
|
},
|
|
{ flush: 'post', immediate: true },
|
|
);
|
|
onActivated(() => {
|
|
align();
|
|
});
|
|
onBeforeUnmount(() => {
|
|
cancelKeepAlign();
|
|
});
|
|
return () => {
|
|
return <Tooltip ref={innerRef} {...props} {...attrs} v-slots={slots} />;
|
|
};
|
|
},
|
|
});
|