types(runtime-core): improve types for transition hook

fix #1000
This commit is contained in:
likui 2020-04-21 12:06:10 +08:00
parent 6fefeafe98
commit 9bddf3820e
2 changed files with 10 additions and 10 deletions

View File

@ -43,14 +43,14 @@ export interface BaseTransitionProps<HostElement = RendererElement> {
onLeaveCancelled?: (el: HostElement) => void // only fired in persisted mode
}
export interface TransitionHooks {
export interface TransitionHooks<HostElement = RendererElement> {
persisted: boolean
beforeEnter(el: RendererElement): void
enter(el: RendererElement): void
leave(el: RendererElement, remove: () => void): void
beforeEnter(el: HostElement): void
enter(el: HostElement): void
leave(el: HostElement, remove: () => void): void
afterLeave?(): void
delayLeave?(
el: RendererElement,
el: HostElement,
earlyRemove: () => void,
delayedLeave: () => void
): void
@ -270,9 +270,9 @@ export function resolveTransitionHooks(
)
}
const hooks: TransitionHooks = {
const hooks: TransitionHooks<TransitionElement> = {
persisted,
beforeEnter(el: TransitionElement) {
beforeEnter(el) {
if (!appear && !state.isMounted) {
return
}
@ -293,7 +293,7 @@ export function resolveTransitionHooks(
callHook(onBeforeEnter, [el])
},
enter(el: TransitionElement) {
enter(el) {
if (!appear && !state.isMounted) {
return
}
@ -318,7 +318,7 @@ export function resolveTransitionHooks(
}
},
leave(el: TransitionElement, remove) {
leave(el, remove) {
const key = String(vnode.key)
if (el._enterCb) {
el._enterCb(true /* cancelled */)

View File

@ -107,7 +107,7 @@ export interface VNode<HostNode = RendererNode, HostElement = RendererElement> {
component: ComponentInternalInstance | null
suspense: SuspenseBoundary | null
dirs: DirectiveBinding[] | null
transition: TransitionHooks | null
transition: TransitionHooks<HostElement> | null
// DOM
el: HostNode | null