UNPKG

react-dates

Version:

A responsive and accessible date range picker component built with React

18 lines (15 loc) 501 B
import { ANCHOR_LEFT } from '../../constants'; export default function getResponsiveContainerStyles( anchorDirection, currentOffset, containerEdge, margin, ) { const windowWidth = typeof window !== 'undefined' && window.innerWidth; const calculatedOffset = anchorDirection === ANCHOR_LEFT ? windowWidth - containerEdge : containerEdge; const calculatedMargin = margin || 0; return { [anchorDirection]: Math.min(currentOffset + calculatedOffset - calculatedMargin, 0), }; }