perf: trigger animation

This commit is contained in:
tanjinzhou 2020-04-21 16:13:17 +08:00
parent f9b233f39d
commit bf52f73c5c
5 changed files with 35 additions and 26 deletions

View File

@ -42,7 +42,7 @@ export default {
renderComponent(props = {}, ready) {
const { visible, forceRender, getContainer, parent } = this;
const self = this;
if (visible || parent.$refs._component || forceRender) {
if (visible || parent._component || parent.$refs._component || forceRender) {
let el = this.componentEl;
if (!this.container) {
this.container = getContainer();
@ -50,12 +50,14 @@ export default {
this.componentEl = el;
this.container.appendChild(el);
}
// self.getComponent render render
const com = { component: self.getComponent(props) };
if (!this._component) {
this._component = new this.$root.constructor({
el,
parent: self,
data: {
comProps: props,
_com: com,
},
mounted() {
this.$nextTick(() => {
@ -72,17 +74,16 @@ export default {
});
},
methods: {
forceRender(p) {
this.comProps = p;
this.$forceUpdate();
setComponent(_com) {
this.$data._com = _com;
},
},
render() {
return self.getComponent(this.comProps);
return this.$data._com.component;
},
});
} else {
this._component.forceRender(props);
this._component.setComponent(com);
}
}
},

View File

@ -32,6 +32,10 @@ export default {
visible(val) {
if (!val) {
this.lastVisible = val;
} else {
this.$nextTick(() => {
this.scrollActiveItemToView();
});
}
},
},
@ -50,11 +54,11 @@ export default {
},
updated() {
const props = this.$props;
if (!this.prevVisible && props.visible) {
this.$nextTick(() => {
this.scrollActiveItemToView();
});
}
// if (!this.prevVisible && props.visible) {
// this.$nextTick(() => {
// this.scrollActiveItemToView();
// });
// }
this.lastVisible = props.visible;
this.lastInputValue = props.inputValue;
this.prevVisible = this.visible;

View File

@ -828,11 +828,10 @@ const Select = {
// When set open success and single mode,
// we will reset the input content.
if (open && !multiple && !treeCheckable && _searchValue) {
//
// this.setUncontrolledState({
// _searchValue: '',
// _filteredTreeNodes: null,
// });
this.setUncontrolledState({
_searchValue: '',
_filteredTreeNodes: null,
});
}
this.setOpenState(open, true);
},

View File

@ -46,12 +46,14 @@ export default {
this.setStretchSize();
});
},
beforeUpdate() {
if (this.domEl && this.domEl.rcEndListener) {
this.domEl.rcEndListener();
this.domEl = null;
}
},
// https://github.com/vueComponent/ant-design-vue/issues/1327
// ()
// beforeUpdate() {
// if (this.domEl && this.domEl.rcEndListener) {
// this.domEl.rcEndListener();
// this.domEl = null;
// }
// },
updated() {
this.$nextTick(() => {
this.setStretchSize();
@ -207,10 +209,10 @@ export default {
style: { ...sizeStyle, ...popupStyle, ...this.getZIndexStyle() },
};
let transitionProps = {
props: Object.assign({
props: {
appear: true,
css: false,
}),
},
};
const transitionName = getTransitionName();
let useTransition = !!transitionName;
@ -227,6 +229,8 @@ export default {
this.domEl = el;
animate(el, `${transitionName}-enter`, done);
});
} else {
done();
}
});
},

View File

@ -128,9 +128,10 @@ export default {
if (this.sPopupVisible !== this.prevPopupVisible) {
this.afterPopupVisibleChange(this.sPopupVisible);
}
this.prevPopupVisible = this.sPopupVisible;
};
this.renderComponent(null, triggerAfterPopupVisibleChange);
this.$nextTick(() => {
this.renderComponent(null, triggerAfterPopupVisibleChange);
this.updatedCal();
});
},