import * as React from 'react'; import { CSSProp } from 'styled-components'; export interface CarouselWrapperProps extends React.HtmlHTMLAttributes { isVisible: boolean; cssStyles?: CSSProp; } export declare type VerticalCarouselScrollOptions = { onScrollStart: (initialIndex: number) => void; onScrollEnd: (targetIndex: number) => void; forceScroll: boolean; }; export declare const DefaultScrollOptions: VerticalCarouselScrollOptions; export declare type ScrollSources = 'props' | 'onload' | 'click' | 'scroll'; export interface Props extends React.RefAttributes> { /** * scrollContainerId is used to determine the scroll element for tweening */ scrollContainerId?: string; children?: React.ReactNode; /** * CSS Interpolation for the wrapper element */ wrapperCss?: CSSProp; wrapperProps?: React.HtmlHTMLAttributes; childWrapperCss?: CSSProp; childWrapperProps?: React.HtmlHTMLAttributes; /** * activeChildIndex is the currently active child element, * where active is defined by */ activeChildIndex: number; /** * Duration of the scroll animation, in seconds */ scrollAnimationDuration?: number; /** * onScrollAnimationStart is triggered when the scroll animation begins */ onScrollAnimationStart?: (startIndex: number) => void; /** * onScrollAnimationStart is triggered when the scroll animation ends */ onScrollAnimationEnd?: (endIndex: number) => void; /** * animatedUserScroll defines whether or not to switch to an animation-controlled * scrolling behavior once a scroll or resize listener has determined a new * activeIndex */ animatedUserScroll?: boolean; /** * Set a custom gsap overwrite value for the scroll tween */ scrollTweenOverwrite?: 'none' | 'all' | 'auto' | 'concurrent' | 'allOnStart' | 'preexisting'; /** * setActiveIndex * @param index: the new index of a child to update */ setActiveIndex: (index: number) => void; /** * disableAutoKill disables animation killing due to scrolling effects. * By default, disableAutoKill is false, unless animatedUserScroll is applied. * * When animatedUserScroll is applied, this prop's value is ignored and * autoKill is disabled. */ disableAutoKill?: boolean; /** * isElementOversized is a function that determines whether or not a child element is to be * considered "oversized". By default, any element that is taller than the client height * is to be considered "oversized". * @param {number} elementHeight: the height of the element in px * @param {number} clientHeight: the height of the client in px * @returns {boolean} */ isElementOversized?: (elementHeight: number, clientHeight: number) => boolean; /** * getElementOffset determines the vertical offset in pixels for a scroll tween and * provides whether or not the element in question is taller than the current screen. * @param {boolean} isOversized: is the element oversized * @returns {number} the offset in pixels */ getElementOffset?: (isOversized?: boolean) => number; /** * * @param {number} targetIndex * @param {number} currentIndex * @returns {boolean} */ shouldScrollToIndex?: (targetIndex: number, currentIndex: number, source: CustomScrollSources | ScrollSources) => boolean; /** * Numeric value from 0 to 1 that defines where the boundary for * detecting the current "active" child should be located. * * Note: This is also used to determine where to scroll to on a page. * @default: 0.45 */ activeChildBoundaryRatio?: number; /** * getChildZIndex returns a z-index value for a child given its elementIndex, if defined. * @param {number} elementIndex * @returns {number} */ getChildZIndex?: (elementIndex: number) => number; } export interface State { /** * Is this a web browser (client), instead of a * server (NodeJS) */ isClient: boolean; /** * Is there a scroll animation happening already? */ isScrolling: boolean; /** * The form starts off invisible to hide the initial scroll to its first element */ isVisible: boolean; /** * opaqueChildIndex is the index of the child that is currently fully opaque and * thereby "visually" active, irrespective of the functionally active child index, * which is managed by the controlled prop activeChildIndex */ opaqueChildIndex: number; } export declare class Carousel extends React.PureComponent, State> { wrapperRef: React.RefObject; timer: any; static defaultProps: Required, 'activeChildBoundaryRatio'>>; constructor(props: Props); componentDidMount(): void; componentDidUpdate(prevProps: Readonly>, prevState: Readonly, snapshot?: any): void; componentWillUnmount(): void; /** * getScrollYTarget determines the target scrollY for the element * at a specific index. * * If the element is smaller than the screen height, it will be centered on screen. * If it is not, the element will be at the top of the page. * @param index */ getScrollYTarget: (index: number) => number | null; /** * scrollToIndex uses a scroll tween to scroll to the element corresponding to * the index parameter * @param targetIndex * @param source * @param options, */ scrollToIndex: (targetIndex: number, source: "click" | "scroll" | CustomScrollSources | "props" | "onload", options?: Partial | undefined) => void; /** * getChildElements gets the child elements of the carousel wrapper * @returns {Array | null} */ getChildElements: () => Element[] | null; /** * getContainerElementOrFallback uses an id to get a specific DOM element * @param id: the id of the element * @param fallback: the fallback element */ getContainerElementOrFallback: (id: string, fallback: T) => HTMLElement | T; /** * getEventListenersTarget gets the DOM element for attaching the scroll and resize * event listeners */ getEventListenersTarget: () => HTMLElement | Window; /** * getScrollContainerElement gets the DOM element to use as the target * for the scroll tween */ getScrollContainerElement: () => HTMLElement; getMiddleElementStruct: (elements: Element[], event?: Event | undefined) => import("./utils").ElementIndexStruct | null; /** * opaqueChildIndexHandler * @param {Event} event */ opaqueChildIndexHandler: (event: Event) => void; opaqueChildScrollHandler: (event: Event) => void; opaqueChildResizeHandler: (event: Event) => void; render(): JSX.Element | null; } export default Carousel;