mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 18:48:45 +08:00
popOver支持offset
This commit is contained in:
parent
bc05446d31
commit
1d9dfa5d83
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user