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

View File

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

View File

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

View File

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

View File

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