Browse Source

ensure leaving transitions are up-to-date for dynamic transitions

dev
Evan You 8 years ago
parent
commit
27c221b430
  1. 1
      src/platforms/web/runtime/components/transition-group.js
  2. 9
      src/platforms/web/runtime/components/transition.js

1
src/platforms/web/runtime/components/transition-group.js

@ -61,6 +61,7 @@ export default {
const removed = [] const removed = []
for (let i = 0; i < prevChildren.length; i++) { for (let i = 0; i < prevChildren.length; i++) {
const c = prevChildren[i] const c = prevChildren[i]
c.data.transition = transitionData
c.data.pos = c.elm.getBoundingClientRect() c.data.pos = c.elm.getBoundingClientRect()
if (map[c.key]) { if (map[c.key]) {
kept.push(c) kept.push(c)

9
src/platforms/web/runtime/components/transition.js

@ -4,7 +4,7 @@
// supports transition mode (out-in / in-out) // supports transition mode (out-in / in-out)
import { warn } from 'core/util/index' import { warn } from 'core/util/index'
import { camelize } from 'shared/util' import { camelize, extend } from 'shared/util'
import { getRealChild, mergeVNodeHook } from 'core/vdom/helpers' import { getRealChild, mergeVNodeHook } from 'core/vdom/helpers'
export const transitionProps = { export const transitionProps = {
@ -100,9 +100,12 @@ export default {
const oldRawChild = this._vnode const oldRawChild = this._vnode
const oldChild: any = getRealChild(oldRawChild) const oldChild: any = getRealChild(oldRawChild)
if (oldChild && oldChild.data && oldChild.key !== child.key) {
// replace old child transition data with fresh one
// important for dynamic transitions!
const oldData = oldChild.data.transition = extend({}, data)
// handle transition mode // handle transition mode
if (mode && oldChild && oldChild.data && oldChild.key !== child.key) {
const oldData = oldChild.data.transition
if (mode === 'out-in') { if (mode === 'out-in') {
// return empty node and queue update when leave finishes // return empty node and queue update when leave finishes
mergeVNodeHook(oldData, 'afterLeave', () => { mergeVNodeHook(oldData, 'afterLeave', () => {

Loading…
Cancel
Save