UNPKG

json-joy

Version:

Collection of libraries for building collaborative editing apps.

31 lines 1.08 kB
import * as React from 'react'; import { rule } from 'nano-theme'; import { EntangledPortal } from '../../../../components/EntangledPortal'; const spanClass = rule({ pe: 'none', }); const gap = 4; const position = (base, dest) => { let x = base.x - (dest.width >> 1); let y = base.y; if (x < gap) x = gap; else if (x + dest.width + gap > window.innerWidth) x = window.innerWidth - dest.width - gap; const { scrollY } = window; const body = document.body; const html = document.documentElement; const pageHeight = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight); if (base.y + dest.height + scrollY > pageHeight) y = base.y - (base.y + dest.height + scrollY - pageHeight); return [x, y]; }; const span = { className: spanClass }; const entangledProps = { position, span, }; export const BottomPanePortal = ({ children }) => { return React.createElement(EntangledPortal, { ...entangledProps }, children); }; //# sourceMappingURL=BottomPanePortal.js.map