mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat: add onPopupReopen (#8641)
This commit is contained in:
parent
161b5980eb
commit
b43822562f
19
src/composables/on-popup-reopen.ts
Normal file
19
src/composables/on-popup-reopen.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { inject, watch } from 'vue';
|
||||||
|
|
||||||
|
// eslint-disable-next-line
|
||||||
|
export const POPUP_TOGGLE_KEY = Symbol();
|
||||||
|
|
||||||
|
export function onPopupReopen(callback: () => void) {
|
||||||
|
const popupToggleStatus = inject<(() => boolean) | null>(
|
||||||
|
POPUP_TOGGLE_KEY,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
if (popupToggleStatus) {
|
||||||
|
watch(popupToggleStatus, (show) => {
|
||||||
|
if (show) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
ref,
|
ref,
|
||||||
watch,
|
watch,
|
||||||
|
provide,
|
||||||
Teleport,
|
Teleport,
|
||||||
computed,
|
computed,
|
||||||
PropType,
|
PropType,
|
||||||
@ -21,6 +22,7 @@ import { useEventListener } from '@vant/use';
|
|||||||
import { useExpose } from '../composables/use-expose';
|
import { useExpose } from '../composables/use-expose';
|
||||||
import { useLockScroll } from '../composables/use-lock-scroll';
|
import { useLockScroll } from '../composables/use-lock-scroll';
|
||||||
import { useLazyRender } from '../composables/use-lazy-render';
|
import { useLazyRender } from '../composables/use-lazy-render';
|
||||||
|
import { POPUP_TOGGLE_KEY } from '../composables/on-popup-reopen';
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
import { Icon } from '../icon';
|
import { Icon } from '../icon';
|
||||||
@ -245,6 +247,8 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
provide(POPUP_TOGGLE_KEY, () => props.show);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
if (props.teleport) {
|
if (props.teleport) {
|
||||||
return (
|
return (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user