popOver支持offset

This commit is contained in:
hantianjiao 2019-06-13 19:32:50 +08:00
parent bc05446d31
commit 1d9dfa5d83
3 changed files with 14 additions and 9 deletions

View File

@ -163,6 +163,15 @@ export default {
{
name: "platform",
label: "Platform(s)",
popOver: {
body: {
type: "tpl",
tpl: "偏了一点的popover"
},
offset: {
y: 100
}
},
sortable: true,
type: "text",
toggled: true

View File

@ -74,10 +74,9 @@ export class PopOver extends React.PureComponent<PopOverPorps, PopOverState> {
} else {
offset = getOffset as Offset;
}
this.setState({
xOffset: offset ? (offset as Offset).x : 0,
yOffset: offset ? offset.y : 0,
xOffset: (offset && offset.x) ? (offset as Offset).x : 0,
yOffset: (offset && offset.y) ? (offset as Offset).y : 0,
});
}
@ -100,7 +99,6 @@ export class PopOver extends React.PureComponent<PopOverPorps, PopOverState> {
} = this.props;
const {xOffset, yOffset} = this.state;
const outerStyle = {
display: 'block',
...style,

View File

@ -9,11 +9,9 @@ import {RendererProps} from '../factory';
import cx from 'classnames';
import hoistNonReactStatic = require('hoist-non-react-statics');
import {RootCloseWrapper} from 'react-overlays';
import PopOver from '../components/PopOver';
import PopOver, {Offset} from '../components/PopOver';
import Overlay from '../components/Overlay';
export interface PopOverConfig {}
const allowedPositions = ['center', 'top'];
export interface PopOverConfig {
@ -33,6 +31,7 @@ export interface PopOverConfig {
| 'fixed-left-bottom'
| 'fixed-right-bottom';
[propName: string]: any;
offset: Offset;
}
export interface PopOverProps extends RendererProps {
@ -125,7 +124,6 @@ export const HocPopOver = (config: Partial<PopOverConfig> = {}) => (Component: R
renderPopOver() {
let {popOver, render, popOverContainer, classnames: cx, classPrefix: ns} = this.props;
if (
popOver &&
((popOver as PopOverConfig).mode === 'dialog' || (popOver as PopOverConfig).mode === 'drawer')
@ -161,7 +159,7 @@ export const HocPopOver = (config: Partial<PopOverConfig> = {}) => (Component: R
rootClose
show
>
<PopOver classPrefix={ns} className={cx('PopOverAble-popover')}>
<PopOver classPrefix={ns} className={cx('PopOverAble-popover')} offset={popOver.offset}>
{content}
</PopOver>
</Overlay>