UNPKG

react-intersection-observer-ng

Version:

Monitor if a component is inside the viewport, using IntersectionObserver API

33 lines (32 loc) 1.01 kB
import * as React from 'react'; import { IntersectionObserverProps, PlainChildrenProps } from './typings/types'; declare type State = { inView: boolean; entry?: IntersectionObserverEntry; }; /** * Monitors scroll, and triggers the children function with updated props * <InView> {({inView, ref}) => ( <h1 ref={ref}>{`${inView}`}</h1> )} </InView> */ export declare class InView extends React.Component<IntersectionObserverProps | PlainChildrenProps, State> { static displayName: string; static defaultProps: { threshold: number; triggerOnce: boolean; }; state: State; componentDidMount(): void; componentDidUpdate(prevProps: IntersectionObserverProps, prevState: State): void; componentWillUnmount(): void; node: Element | null; observeNode(): void; handleNode: (node?: Element | null | undefined) => void; handleChange: (inView: boolean, entry: IntersectionObserverEntry) => void; render(): {} | null | undefined; } export {};