zent
Version:
一套前端设计语言和基于React的实现
31 lines (27 loc) • 664 B
text/typescript
import { IPositionFunction } from '../position-function';
import { prefix } from './prefix';
/**
* ----------------------
* | |----------
* | anchor | popover |
* | |---------
* |--------------------|
*/
export const RightCenter: IPositionFunction = ({
contentRect,
relativeRect,
cushion,
}) => {
const { right, top, bottom } = relativeRect;
const x = right + cushion;
const middle = (top + bottom) / 2;
const y = middle - contentRect.height / 2;
return {
style: {
position: 'absolute',
left: x,
top: y,
},
className: prefix('position-right-center'),
};
};