Browse Source

really fix out-in mode

Evan You 10 năm trước cách đây
mục cha
commit
582a8932d3

+ 8 - 5
src/platforms/web/runtime/components/transition.js

@@ -60,15 +60,18 @@ export default {
     const oldChild = getRealChild(oldRawChild)
     const oldChild = getRealChild(oldRawChild)
     if (mode && oldChild && oldChild.data && oldChild.key !== child.key) {
     if (mode && oldChild && oldChild.data && oldChild.key !== child.key) {
       if (mode === 'out-in') {
       if (mode === 'out-in') {
-        // return old node
-        // and queue an update when the leave finishes
-        if (!oldChild.elm._leaveCb && oldRawChild.data.transition) {
+        if (
+          !oldChild.elm._leaveCb && // not already leaving
+          oldChild.data.transition // not already left
+        ) {
           leave(oldChild, () => {
           leave(oldChild, () => {
-            oldRawChild.data.transition = null
+            // mark left & avoid triggering leave transition again
+            oldChild.data.transition = null
             this.$forceUpdate()
             this.$forceUpdate()
           })
           })
         }
         }
-        if (oldRawChild.data.transition) {
+        // return old node if not left yet
+        if (oldChild.data.transition) {
           return oldRawChild
           return oldRawChild
         }
         }
       } else if (mode === 'in-out') {
       } else if (mode === 'in-out') {