Skip to content

Commit 35e4e9d

Browse files
fix(MdPortal): get the correct transition duration before removing a portal element
1 parent dcf22cf commit 35e4e9d

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

src/components/MdPortal/MdPortal.vue

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,32 @@
6363
}
6464
},
6565
methods: {
66+
getTransitionDuration () {
67+
const duration = window.getComputedStyle(this.$el).transitionDuration
68+
const num = parseFloat(duration, 10)
69+
let unit = duration.match(/m?s/)
70+
let milliseconds = null
71+
72+
if (unit) {
73+
unit = unit[0]
74+
}
75+
76+
switch (unit) {
77+
case 's':
78+
milliseconds = num * 1000
79+
break
80+
81+
case 'ms':
82+
milliseconds = num
83+
break
84+
85+
default:
86+
milliseconds = 0
87+
break
88+
}
89+
90+
return milliseconds
91+
},
6692
prepareSlotRender ($slots) {
6793
const slotNames = Object.keys($slots)
6894
@@ -103,7 +129,7 @@
103129
this.$el.classList.add(this.leaveToClass)
104130
105131
window.clearTimeout(this.leaveTimeout)
106-
this.leaveTimeout = window.setTimeout(this.destroyElement, 400)
132+
this.leaveTimeout = window.setTimeout(this.destroyElement, this.getTransitionDuration())
107133
} else {
108134
this.killGhostElement()
109135
}

0 commit comments

Comments
 (0)