import classNames from 'classnames'; import { JsxChildren } from 'dom-renderer'; import { FC, WebCellProps } from 'web-cell'; export type EdgePosition = 'top' | 'bottom' | 'left' | 'right'; export type TouchHandler = (edge: EdgePosition) => any; export interface ScrollBoundaryProps extends WebCellProps, Partial> { onTouch: TouchHandler; } function touch(edge: EdgePosition, onTouch: TouchHandler) { return (node: HTMLElement | null) => node && new IntersectionObserver( ([{ isIntersecting }]) => isIntersecting && onTouch(edge) ).observe(node); } export const ScrollBoundary: FC = ({ className, onTouch, top, left, right, bottom, children }) => (
{top}
{left}
{children}
{right}
{bottom}
);