8000 allow transition to specify CSS transition type · vuejs/vue@f04b396 · GitHub
[go: up one dir, main page]

Skip to content

Commit f04b396

Browse files
committed
allow transition to specify CSS transition type
1 parent fdbea49 commit f04b396

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/transition/transition.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ import {
99
transitionEndEvent,
1010
animationEndEvent,
1111
transitionProp,
12-
animationProp
12+
animationProp,
13+
warn
1314
} from '../util/index'
1415

15-
const TYPE_TRANSITION = 1
16-
const TYPE_ANIMATION = 2
16+
const TYPE_TRANSITION = 'transition'
17+
const TYPE_ANIMATION = 'animation'
1718
const transDurationProp = transitionProp + 'Duration'
1819
const animDurationProp = animationProp + 'Duration'
1920

@@ -44,6 +45,21 @@ export default function Transition (el, id, hooks, vm) {
4445
this.justEntered = false
4546
this.entered = this.left = false
4647
this.typeCache = {}
48+
// check css transition type
49+
this.type = hooks && hooks.type
50+
/* istanbul ignore if */
51+
if (process.env.NODE_ENV !== 'production') {
52+
if (
53+
this.type &&
54+
this.type !== TYPE_TRANSITION &&
55+
this.type !== TYPE_ANIMATION
56+
) {
57+
warn(
58+
'invalid CSS transition type for transition="' +
59+
this.id + '": ' + this.type
60+
)
61+
}
62+
}
4763
// bind
4864
var self = this
4965
;['enterNextTick', 'enterDone', 'leaveNextTick', 'leaveDone']
@@ -309,7 +325,7 @@ p.getCssTransitionType = function (className) {
309325
) {
310326
return
311327
}
312-
var type = this.typeCache[className]
328+
var type = this.type || this.typeCache[className]
313329
if (type) return type
314330
var inlineStyles = this.el.style
315331
var computedStyles = window.getComputedStyle(this.el)

0 commit comments

Comments
 (0)
0