parent
3a79f72816
commit
bb443a05e2
@ -1,21 +1,25 @@
|
|||||||
import type { ComponentInternalInstance, ComputedRef, Ref } from 'vue';
|
import type { ComputedRef, Ref } from 'vue';
|
||||||
|
import { onBeforeUnmount, getCurrentInstance } from 'vue';
|
||||||
import { findDOMNode } from '../props-util';
|
import { findDOMNode } from '../props-util';
|
||||||
import showWaveEffect from './WaveEffect';
|
import showWaveEffect from './WaveEffect';
|
||||||
|
|
||||||
export default function useWave(
|
export default function useWave(
|
||||||
instance: ComponentInternalInstance | null,
|
|
||||||
className: Ref<string>,
|
className: Ref<string>,
|
||||||
wave?: ComputedRef<{ disabled?: boolean }>,
|
wave?: ComputedRef<{ disabled?: boolean }>,
|
||||||
): VoidFunction {
|
): VoidFunction {
|
||||||
|
const instance = getCurrentInstance();
|
||||||
|
let stopWave: () => void;
|
||||||
function showWave() {
|
function showWave() {
|
||||||
const node = findDOMNode(instance);
|
const node = findDOMNode(instance);
|
||||||
|
stopWave?.();
|
||||||
if (wave?.value?.disabled || !node) {
|
if (wave?.value?.disabled || !node) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
stopWave = showWaveEffect(node, className.value);
|
||||||
showWaveEffect(node, className.value);
|
|
||||||
}
|
}
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
stopWave?.();
|
||||||
|
});
|
||||||
|
|
||||||
return showWave;
|
return showWave;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in new issue