PopOver 弹出时给容器dom节点添加 has-popover 类名

This commit is contained in:
liaoxuezhi 2019-07-17 09:41:56 +08:00
parent bc3a8fb0d9
commit df352d65e8
1 changed files with 9 additions and 0 deletions

View File

@ -52,14 +52,23 @@ export class PopOver extends React.PureComponent<PopOverPorps, PopOverState> {
yOffset: 0, yOffset: 0,
}; };
parent:HTMLElement;
componentDidMount() { componentDidMount() {
this.mayUpdateOffset(); this.mayUpdateOffset();
const dom = findDOMNode(this) as HTMLElement;
this.parent = dom.parentNode as HTMLElement;
this.parent.classList.add('has-popover');
} }
componentDidUpdate() { componentDidUpdate() {
this.mayUpdateOffset(); this.mayUpdateOffset();
} }
componentWillUnmount() {
this.parent && this.parent.classList.remove('has-popover');
}
mayUpdateOffset() { mayUpdateOffset() {
let offset: Offset; let offset: Offset;
let getOffset = this.props.offset; let getOffset = this.props.offset;