Browse Source

reduce indent

dev
Evan You 9 years ago
parent
commit
d2fa013ba4
  1. 155
      src/runtime/dom-backend/modules/transition.js

155
src/runtime/dom-backend/modules/transition.js

@ -32,101 +32,102 @@ function nextFrame (fn) {
function beforeEnter (_, vnode) {
const el = vnode.elm
const data = vnode.data.transition
if (data != null) {
const {
enterClass,
enterActiveClass,
beforeEnter,
enter,
afterEnter,
enterCancelled
} = detectAuto(data)
const userWantsControl = enter && enter.length > 1
const cb = el._enterCb = () => {
// ensure only called once
if (cb.called) {
return
}
cb.called = true
if (enterActiveClass) {
removeTransitionClass(el, enterActiveClass)
}
if (cb.cancelled) {
enterCancelled && enterCancelled(el)
} else {
afterEnter && afterEnter(el)
}
el._enterCb = null
}
if (data == null) {
return
}
beforeEnter && beforeEnter(el)
if (enterClass) {
addTransitionClass(el, enterClass)
nextFrame(() => {
removeTransitionClass(el, enterClass)
})
const {
enterClass,
enterActiveClass,
beforeEnter,
enter,
afterEnter,
enterCancelled
} = detectAuto(data)
const userWantsControl = enter && enter.length > 1
const cb = el._enterCb = () => {
// ensure only called once
if (cb.called) {
return
}
cb.called = true
if (enterActiveClass) {
nextFrame(() => {
addTransitionClass(el, enterActiveClass)
if (!userWantsControl) {
whenTransitionEnds(el, cb)
}
})
removeTransitionClass(el, enterActiveClass)
}
enter && enter(el, cb)
if (!enterActiveClass && !userWantsControl) {
cb()
if (cb.cancelled) {
enterCancelled && enterCancelled(el)
} else {
afterEnter && afterEnter(el)
}
el._enterCb = null
}
beforeEnter && beforeEnter(el)
if (enterClass) {
addTransitionClass(el, enterClass)
nextFrame(() => {
removeTransitionClass(el, enterClass)
})
}
if (enterActiveClass) {
nextFrame(() => {
addTransitionClass(el, enterActiveClass)
if (!userWantsControl) {
whenTransitionEnds(el, cb)
}
})
}
enter && enter(el, cb)
if (!enterActiveClass && !userWantsControl) {
cb()
}
}
function onLeave (vnode, rm) {
const el = vnode.elm
if (!el) return
// call enter callback now
if (el._enterCb) {
el._enterCb.cancelled = true
el._enterCb()
}
const data = vnode.data.transition
if (data != null) {
const {
leaveClass,
leaveActiveClass,
beforeLeave,
leave,
afterLeave
} = detectAuto(data)
const userWantsControl = leave && leave.length > 1
const cb = () => {
rm()
afterLeave && afterLeave(el)
}
if (data == null) {
return rm()
}
beforeLeave && beforeLeave(el)
if (leaveClass) {
addTransitionClass(el, leaveClass)
nextFrame(() => {
removeTransitionClass(el, leaveClass)
})
}
if (leaveActiveClass) {
nextFrame(() => {
addTransitionClass(el, leaveActiveClass)
if (!userWantsControl) {
whenTransitionEnds(el, cb)
}
})
}
leave && leave(el, cb)
if (!leaveActiveClass && !userWantsControl) {
cb()
}
} else {
const {
leaveClass,
leaveActiveClass,
beforeLeave,
leave,
afterLeave
} = detectAuto(data)
const userWantsControl = leave && leave.length > 1
const cb = () => {
rm()
afterLeave && afterLeave(el)
}
beforeLeave && beforeLeave(el)
if (leaveClass) {
addTransitionClass(el, leaveClass)
nextFrame(() => {
removeTransitionClass(el, leaveClass)
})
}
if (leaveActiveClass) {
nextFrame(() => {
addTransitionClass(el, leaveActiveClass)
if (!userWantsControl) {
whenTransitionEnds(el, cb)
}
})
}
leave && leave(el, cb)
if (!leaveActiveClass && !userWantsControl) {
cb()
}
}

Loading…
Cancel
Save