You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ant-design-vue/components/_util/wave/useWave.ts

26 lines
659 B

import type { ComputedRef, Ref } from 'vue';
import { onBeforeUnmount, getCurrentInstance } from 'vue';
import { findDOMNode } from '../props-util';
import showWaveEffect from './WaveEffect';
export default function useWave(
className: Ref<string>,
wave?: ComputedRef<{ disabled?: boolean }>,
): VoidFunction {
const instance = getCurrentInstance();
let stopWave: () => void;
function showWave() {
const node = findDOMNode(instance);
stopWave?.();
if (wave?.value?.disabled || !node) {
return;
}
stopWave = showWaveEffect(node, className.value);
}
onBeforeUnmount(() => {
stopWave?.();
});
return showWave;
}