({
popper,
popperRect,
placement,
variation,
offsets,
position,
gpuAcceleration,
adaptive,
roundOffsets,
isFixed,
}: {
popper: HTMLElement,
popperRect: Rect,
placement: BasePlacement,
variation: ?Variation,
offsets: $Shape<{ x: number, y: number, centerOffset: number }>,
position: PositioningStrategy,
gpuAcceleration: boolean,
adaptive: boolean,
roundOffsets: boolean | RoundOffsets,
isFixed: boolean,
})
| 56 | } |
| 57 | |
| 58 | export function mapToStyles({ |
| 59 | popper, |
| 60 | popperRect, |
| 61 | placement, |
| 62 | variation, |
| 63 | offsets, |
| 64 | position, |
| 65 | gpuAcceleration, |
| 66 | adaptive, |
| 67 | roundOffsets, |
| 68 | isFixed, |
| 69 | }: { |
| 70 | popper: HTMLElement, |
| 71 | popperRect: Rect, |
| 72 | placement: BasePlacement, |
| 73 | variation: ?Variation, |
| 74 | offsets: $Shape<{ x: number, y: number, centerOffset: number }>, |
| 75 | position: PositioningStrategy, |
| 76 | gpuAcceleration: boolean, |
| 77 | adaptive: boolean, |
| 78 | roundOffsets: boolean | RoundOffsets, |
| 79 | isFixed: boolean, |
| 80 | }) { |
| 81 | let { x = 0, y = 0 } = offsets; |
| 82 | |
| 83 | ({ x, y } = |
| 84 | typeof roundOffsets === 'function' ? roundOffsets({ x, y }) : { x, y }); |
| 85 | |
| 86 | const hasX = offsets.hasOwnProperty('x'); |
| 87 | const hasY = offsets.hasOwnProperty('y'); |
| 88 | |
| 89 | let sideX: string = left; |
| 90 | let sideY: string = top; |
| 91 | |
| 92 | const win: Window = window; |
| 93 | |
| 94 | if (adaptive) { |
| 95 | let offsetParent = getOffsetParent(popper); |
| 96 | let heightProp = 'clientHeight'; |
| 97 | let widthProp = 'clientWidth'; |
| 98 | |
| 99 | if (offsetParent === getWindow(popper)) { |
| 100 | offsetParent = getDocumentElement(popper); |
| 101 | |
| 102 | if ( |
| 103 | getComputedStyle(offsetParent).position !== 'static' && |
| 104 | position === 'absolute' |
| 105 | ) { |
| 106 | heightProp = 'scrollHeight'; |
| 107 | widthProp = 'scrollWidth'; |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it |
| 112 | offsetParent = (offsetParent: Element); |
| 113 | |
| 114 | if ( |
| 115 | placement === top || |
no test coverage detected