UNPKG

react-fader

Version:

component that fades out old children, then fades in new children when its children change

82 lines (81 loc) 3.41 kB
import * as React from 'react'; import Prefixer from 'inline-style-prefixer'; export type TransitionState = 'in' | 'out' | 'entering' | 'leaving'; export type DefaultProps = { fadeInTransitionDuration: number; fadeInTransitionTimingFunction: string; fadeOutTransitionDuration: number; fadeOutTransitionTimingFunction: string; sizeTransitionDuration: number; sizeTransitionTimingFunction: string; prefixer: Prefixer; style: any; shouldTransition: (oldChildren?: any, newChildren?: any) => boolean; measureHeight: (el: HTMLElement) => number; measureWidth: (el: HTMLElement) => number; }; export type Props = { animateHeight?: boolean | null | undefined; animateWidth?: boolean | null | undefined; measureHeight?: (el: HTMLElement) => number; measureWidth?: (el: HTMLElement) => number; innerRef?: (c?: React.ElementRef<'div'> | null | undefined) => any | null | undefined; shouldTransition?: (oldChildren?: any, newChildren?: any) => boolean | null | undefined; children?: React.ReactNode | null | undefined; fadeInTransitionDuration?: number | null | undefined; fadeInTransitionTimingFunction?: string | null | undefined; fadeOutTransitionDuration?: number | null | undefined; fadeOutTransitionTimingFunction?: string | null | undefined; sizeTransitionDuration?: number | null | undefined; sizeTransitionTimingFunction?: string | null | undefined; prefixer?: Prefixer | null | undefined; style?: any | null | undefined; viewStyle?: any | null | undefined; innerViewWrapperStyle?: any | null | undefined; className?: string | null | undefined; }; export type DefaultedProps = { animateHeight?: boolean | null | undefined; animateWidth?: boolean | null | undefined; measureHeight: (el: HTMLElement) => number; measureWidth: (el: HTMLElement) => number; innerRef?: (c?: React.ElementRef<'div'> | null | undefined) => any; shouldTransition: (oldChildren?: any, newChildren?: any) => boolean; children?: React.ReactNode; fadeInTransitionDuration: number; fadeInTransitionTimingFunction: string; fadeOutTransitionDuration: number; fadeOutTransitionTimingFunction: string; sizeTransitionDuration: number; sizeTransitionTimingFunction: string; prefixer: Prefixer; style: any; viewStyle?: any | null | undefined; innerViewWrapperStyle?: any | null | undefined; className?: string; }; export type State = { children: any; height: number | null | undefined; width: number | null | undefined; wrappedChildren: React.ReactElement<any>; transitionState: TransitionState; transitioningSize: boolean; }; export default class Fader extends React.Component<Props, State> { lastProps: Props; lastDefaultedProps: DefaultedProps | null | undefined; getDefaultedProps: () => DefaultedProps; wrapChildren: (children: any, transitionState: TransitionState) => React.ReactElement<React.ComponentProps<'div'>>; wrappedChildrenRef: HTMLElement | null | undefined; timeouts: { [name: string]: any; }; state: State; setTimeout(name: string, callback: () => any, delay: number): void; componentDidUpdate(): void; onTransitionEnd: () => void; onSizeTransitionEnd: () => void; componentWillUnmount(): void; render(): React.ReactElement<React.ComponentProps<'div'>>; }