Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check enterToClass/leaveToClass existence before adding it #5912

Merged
merged 3 commits into from
Jun 30, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/platforms/web/runtime/modules/transition.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
nextFrame,
resolveTransition,
whenTransitionEnds,
hasTransitionClass,
addTransitionClass,
removeTransitionClass
} from '../transition-util'
Expand Down Expand Up @@ -149,7 +150,9 @@ export function enter (vnode: VNodeWithData, toggleDisplay: ?() => void) {
addTransitionClass(el, startClass)
addTransitionClass(el, activeClass)
nextFrame(() => {
addTransitionClass(el, toClass)
if (!hasTransitionClass(el, toClass)) {
addTransitionClass(el, toClass)
}
removeTransitionClass(el, startClass)
if (!cb.cancelled && !userWantsControl) {
if (isValidDuration(explicitEnterDuration)) {
Expand Down Expand Up @@ -257,7 +260,9 @@ export function leave (vnode: VNodeWithData, rm: Function) {
addTransitionClass(el, leaveClass)
addTransitionClass(el, leaveActiveClass)
nextFrame(() => {
addTransitionClass(el, leaveToClass)
if (!hasTransitionClass(el, leaveToClass)) {
addTransitionClass(el, leaveToClass)
}
removeTransitionClass(el, leaveClass)
if (!cb.cancelled && !userWantsControl) {
if (isValidDuration(explicitLeaveDuration)) {
Expand Down
4 changes: 4 additions & 0 deletions src/platforms/web/runtime/transition-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ export function nextFrame (fn: Function) {
})
}

export function hasTransitionClass (el: any, cls: string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to just check this directly inside addTransitionClass.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put hasTransitionClass check only inside nextFrame is trying to avoid unnecessary checking. It fair to put it inside addTransitionClass.

return el._transitionClasses && el._transitionClasses.indexOf(cls) > -1
}

export function addTransitionClass (el: any, cls: string) {
(el._transitionClasses || (el._transitionClasses = [])).push(cls)
addClass(el, cls)
Expand Down