[improvement] Transition: remove classNames from data

fix #1761
This commit is contained in:
rex 2019-07-15 10:46:15 +08:00 committed by GitHub
parent 7f2c9c1b58
commit 56c3f5529b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 14 deletions

View File

@ -25,16 +25,14 @@ export const transition = function(showDefaultValue: boolean) {
},
name: {
type: String,
value: 'fade',
observer: 'updateClasses'
value: 'fade'
}
},
data: {
type: '',
inited: false,
display: false,
classNames: getClassNames('fade')
display: false
},
attached() {
@ -52,14 +50,9 @@ export const transition = function(showDefaultValue: boolean) {
}
},
updateClasses(name: string) {
this.set({
classNames: getClassNames(name)
});
},
enter() {
const { classNames, duration } = this.data;
const { duration, name } = this.data;
const classNames = getClassNames(name);
const currentDuration = isObj(duration) ? duration.leave : duration;
this.status = 'enter';
@ -88,7 +81,8 @@ export const transition = function(showDefaultValue: boolean) {
},
leave() {
const { classNames, duration } = this.data;
const { duration, name } = this.data;
const classNames = getClassNames(name);
const currentDuration = isObj(duration) ? duration.leave : duration;
this.status = 'leave';

View File

@ -55,11 +55,16 @@ VantComponent({
observeClass() {
const { transition, position } = this.data;
this.updateClasses(transition || position);
const updateData: { [key: string]: any } = {
name: transition || position
};
if (transition === 'none') {
this.set({ duration: 0 });
updateData.duration = 0;
}
this.set(updateData);
}
}
});