|
|
@ -3,10 +3,10 @@ import PropTypes from '../_util/vue-types';
|
|
|
|
import Align from '../vc-align';
|
|
|
|
import Align from '../vc-align';
|
|
|
|
import PopupInner from './PopupInner';
|
|
|
|
import PopupInner from './PopupInner';
|
|
|
|
import LazyRenderBox from './LazyRenderBox';
|
|
|
|
import LazyRenderBox from './LazyRenderBox';
|
|
|
|
import animate from '../_util/css-animation';
|
|
|
|
|
|
|
|
import BaseMixin from '../_util/BaseMixin';
|
|
|
|
import BaseMixin from '../_util/BaseMixin';
|
|
|
|
import { saveRef } from './utils';
|
|
|
|
import { saveRef } from './utils';
|
|
|
|
import { splitAttrs, findDOMNode } from '../_util/props-util';
|
|
|
|
import { splitAttrs, findDOMNode } from '../_util/props-util';
|
|
|
|
|
|
|
|
import getTransitionProps from '../_util/getTransitionProps';
|
|
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
export default {
|
|
|
|
name: 'VCTriggerPopup',
|
|
|
|
name: 'VCTriggerPopup',
|
|
|
@ -37,6 +37,7 @@ export default {
|
|
|
|
data() {
|
|
|
|
data() {
|
|
|
|
this.domEl = null;
|
|
|
|
this.domEl = null;
|
|
|
|
this.currentAlignClassName = undefined;
|
|
|
|
this.currentAlignClassName = undefined;
|
|
|
|
|
|
|
|
this.transitionProps = {};
|
|
|
|
this.savePopupRef = saveRef.bind(this, 'popupInstance');
|
|
|
|
this.savePopupRef = saveRef.bind(this, 'popupInstance');
|
|
|
|
this.saveAlignRef = saveRef.bind(this, 'alignInstance');
|
|
|
|
this.saveAlignRef = saveRef.bind(this, 'alignInstance');
|
|
|
|
return {
|
|
|
|
return {
|
|
|
@ -73,7 +74,7 @@ export default {
|
|
|
|
// FIX: https://github.com/react-component/tooltip/issues/79
|
|
|
|
// FIX: https://github.com/react-component/tooltip/issues/79
|
|
|
|
if (this.currentAlignClassName !== currentAlignClassName) {
|
|
|
|
if (this.currentAlignClassName !== currentAlignClassName) {
|
|
|
|
this.currentAlignClassName = currentAlignClassName;
|
|
|
|
this.currentAlignClassName = currentAlignClassName;
|
|
|
|
popupDomNode.className = this.getClassName(currentAlignClassName);
|
|
|
|
popupDomNode.className = this.getClassName(currentAlignClassName, popupDomNode.className);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const { onaAlign } = this.$attrs;
|
|
|
|
const { onaAlign } = this.$attrs;
|
|
|
|
onaAlign && onaAlign(popupDomNode, align);
|
|
|
|
onaAlign && onaAlign(popupDomNode, align);
|
|
|
@ -148,10 +149,19 @@ export default {
|
|
|
|
return transitionName;
|
|
|
|
return transitionName;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
getClassName(currentAlignClassName) {
|
|
|
|
getClassName(currentAlignClassName, originClassName = '') {
|
|
|
|
|
|
|
|
// 保留动画 class
|
|
|
|
|
|
|
|
const enterActiveClass = [
|
|
|
|
|
|
|
|
...(this.transitionProps?.enterActiveClass?.split(' ') || []),
|
|
|
|
|
|
|
|
...(this.transitionProps?.appearActiveClass?.split(' ') || []),
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
const classNames = originClassName
|
|
|
|
|
|
|
|
.split(' ')
|
|
|
|
|
|
|
|
.filter(c => enterActiveClass.indexOf(c) !== -1)
|
|
|
|
|
|
|
|
.join(' ');
|
|
|
|
return `${this.$props.prefixCls} ${this.$attrs.class || ''} ${
|
|
|
|
return `${this.$props.prefixCls} ${this.$attrs.class || ''} ${
|
|
|
|
this.$props.popupClassName
|
|
|
|
this.$props.popupClassName
|
|
|
|
} ${currentAlignClassName}`;
|
|
|
|
} ${currentAlignClassName} ${classNames}`;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
getPopupElement() {
|
|
|
|
getPopupElement() {
|
|
|
|
const { savePopupRef } = this;
|
|
|
|
const { savePopupRef } = this;
|
|
|
@ -209,38 +219,10 @@ export default {
|
|
|
|
ref: savePopupRef,
|
|
|
|
ref: savePopupRef,
|
|
|
|
style: { ...sizeStyle, ...popupStyle, ...style, ...this.getZIndexStyle() },
|
|
|
|
style: { ...sizeStyle, ...popupStyle, ...style, ...this.getZIndexStyle() },
|
|
|
|
};
|
|
|
|
};
|
|
|
|
let transitionProps = {
|
|
|
|
|
|
|
|
appear: true,
|
|
|
|
|
|
|
|
css: false,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
const transitionName = getTransitionName();
|
|
|
|
const transitionName = getTransitionName();
|
|
|
|
let useTransition = !!transitionName;
|
|
|
|
let useTransition = !!transitionName;
|
|
|
|
const transitionEvent = {
|
|
|
|
let transitionProps = getTransitionProps(transitionName);
|
|
|
|
onBeforeEnter: () => {
|
|
|
|
|
|
|
|
// el.style.display = el.__vOriginalDisplay
|
|
|
|
|
|
|
|
// this.alignInstance.forceAlign();
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
onEnter: (el, done) => {
|
|
|
|
|
|
|
|
// render 后 vue 会移除通过animate动态添加的 class导致动画闪动,延迟两帧添加动画class,可以进一步定位或者重写 transition 组件
|
|
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
|
|
if (this.alignInstance) {
|
|
|
|
|
|
|
|
this.alignInstance.$nextTick(() => {
|
|
|
|
|
|
|
|
this.domEl = el;
|
|
|
|
|
|
|
|
animate(el, `${transitionName}-enter`, done);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
done();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
onBeforeLeave: () => {
|
|
|
|
|
|
|
|
this.domEl = null;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
onLeave: (el, done) => {
|
|
|
|
|
|
|
|
animate(el, `${transitionName}-leave`, done);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
transitionProps = { ...transitionProps, ...transitionEvent };
|
|
|
|
|
|
|
|
if (typeof animation === 'object') {
|
|
|
|
if (typeof animation === 'object') {
|
|
|
|
useTransition = true;
|
|
|
|
useTransition = true;
|
|
|
|
transitionProps = { ...transitionProps, ...animation };
|
|
|
|
transitionProps = { ...transitionProps, ...animation };
|
|
|
@ -248,6 +230,7 @@ export default {
|
|
|
|
if (!useTransition) {
|
|
|
|
if (!useTransition) {
|
|
|
|
transitionProps = {};
|
|
|
|
transitionProps = {};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.transitionProps = transitionProps;
|
|
|
|
if (destroyPopupOnHide) {
|
|
|
|
if (destroyPopupOnHide) {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<Transition {...transitionProps}>
|
|
|
|
<Transition {...transitionProps}>
|
|
|
|