zent
Version:
一套前端设计语言和基于React的实现
25 lines (21 loc) • 613 B
JavaScript
import createPlacement from './create';
/**
* -------------------------------
* | popover | anchor |
* |---------| |
* ---------------------
*/
export default createPlacement((anchorBoundingBox, containerBoundingBox, contentDimension, options) => {
const x = anchorBoundingBox.left - contentDimension.width - options.cushion;
const y = anchorBoundingBox.top;
return {
getCSSStyle() {
return {
position: 'absolute',
left: `${Math.round(x)}px`,
top: `${Math.round(y)}px`
};
},
name: 'position-left-top'
};
});