UNPKG

@kiwicom/orbit-components

Version:

Orbit-components is a React component library which provides developers with the easiest possible way of building Kiwi.com’s products.

25 lines (20 loc) 951 B
import { css } from "styled-components"; import { POSITIONS, POPOVER_SPACE_BETWEEN } from "../consts"; var resolvePopoverPosition = function resolvePopoverPosition(_ref) { var position = _ref.position, offset = _ref.offset, containerTop = _ref.containerTop, containerHeight = _ref.containerHeight, popoverHeight = _ref.popoverHeight, overlapped = _ref.overlapped, containerPureTop = _ref.containerPureTop, fixed = _ref.fixed; if (position === POSITIONS.TOP) { return css(["top:", "px;"], Math.floor((fixed ? containerPureTop : containerTop) - popoverHeight - (overlapped ? -containerHeight : POPOVER_SPACE_BETWEEN) - offset.top)); } if (position === POSITIONS.BOTTOM) { return css(["top:", "px;"], Math.floor((fixed ? containerPureTop : containerTop) + (overlapped ? 0 : containerHeight + POPOVER_SPACE_BETWEEN) + offset.top)); } return null; }; export default resolvePopoverPosition;