mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-04 04:58:16 +08:00
perf: trigger animation
This commit is contained in:
parent
f9b233f39d
commit
bf52f73c5c
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -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;
|
||||||
|
@ -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);
|
||||||
},
|
},
|
||||||
|
@ -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();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -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();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user