import { type ScrollerVideoState } from './state.svelte'; interface ScrollerVideoArgs { src: string; scrollerVideoContainer: HTMLElement | string; objectFit?: string; sticky?: boolean; full?: boolean; trackScroll?: boolean; lockScroll?: boolean; transitionSpeed?: number; frameThreshold?: number; useWebCodecs?: boolean; onReady?: () => void; onChange?: (percentage?: number) => void; debug?: boolean; autoplay?: boolean; setVideoPercentage?: (percentage: number, options?: TransitionOptions) => void; resize?: () => void; } export interface TransitionOptions { jump: boolean; transitionSpeed?: number; easing?: ((progress: number) => number) | null; autoplay?: boolean; } /** * ScrollerVideo class for scroll-driven or programmatic video playback with Svelte integration. */ declare class ScrollerVideo { /** * The container element for the video or canvas. * @type {HTMLElement | null} */ container: HTMLElement | null; /** * The original container argument (element or string ID). * @type {Element | string | undefined} */ scrollerVideoContainer: Element | string | undefined; /** * Video source URL. * @type {string} */ src: string; /** * Speed of transitions. * @type {number} */ transitionSpeed: number; /** * Threshold for frame transitions. * @type {number} */ frameThreshold: number; /** * Whether to use WebCodecs for decoding. * @type {boolean} */ useWebCodecs: boolean; /** * CSS object-fit property for video/canvas. * @type {string} */ objectFit: string; /** * Whether to use sticky positioning. * @type {boolean} */ sticky: boolean; /** * Whether to track scroll position. * @type {boolean} */ trackScroll: boolean; /** * Callback when ready. * @type {() => void} */ onReady: () => void; /** * Callback on scroll percentage change. * @type {(percentage?: number) => void} */ onChange: (percentage?: number) => void; /** * Enable debug logging. * @type {boolean} */ debug: boolean; /** * Enable autoplay. * @type {boolean} */ autoplay: boolean; /** * The HTML video element. * @type {HTMLVideoElement | undefined} */ video: HTMLVideoElement | undefined; /** * Current scroll/video percentage (0-1). * @type {number} */ videoPercentage: number; /** * True if browser is Safari. * @type {boolean} */ isSafari: boolean; /** * Current video time in seconds. * @type {number} */ currentTime: number; /** * Target video time in seconds. * @type {number} */ targetTime: number; /** * Canvas for rendering frames (if using WebCodecs). * @type {HTMLCanvasElement | null} */ canvas: HTMLCanvasElement | null; /** * 2D context for the canvas. * @type {CanvasRenderingContext2D | null} */ context: CanvasRenderingContext2D | null; /** * Decoded video frames (if using WebCodecs). * @type {ImageBitmap[] | null} */ frames: ImageBitmap[] | null; /** * Video frame rate. * @type {number} */ frameRate: number; /** * Target scroll position in pixels, if set. * @type {number | null} */ targetScrollPosition: number | null; /** * Current frame index (if using WebCodecs). * @type {number} */ currentFrame: number; /** * True if using WebCodecs for decoding. * @type {boolean} */ usingWebCodecs: boolean; /** * Total video duration in seconds. * @type {number} */ totalTime: number; /** * RequestAnimationFrame ID for transitions. * @type {number | null} */ transitioningRaf: number | null; /** * State object for component-level state. * @type {ScrollerVideoState} */ componentState: ScrollerVideoState; /** * Function to update scroll percentage (set in constructor). * @type {((jump: boolean) => void) | undefined} */ updateScrollPercentage: ((jump: boolean) => void) | undefined; /** * Function to handle resize events (set in constructor). * @type {(() => void) | undefined} */ resize: (() => void) | undefined; /** * Creates a new ScrollerVideo instance. * @param {ScrollerVideoArgs} args - The arguments for initialization. */ constructor({ src, scrollerVideoContainer, objectFit, sticky, full, trackScroll, lockScroll, transitionSpeed, frameThreshold, useWebCodecs, onReady, onChange, debug, autoplay, }: ScrollerVideoArgs); /** * Sets the currentTime of the video as a specified percentage of its total duration. * * @param percentage - The percentage of the video duration to set as the current time. * @param options - Configuration options for adjusting the video playback. * - autoplay: boolean - If true, the video will start playing immediately after setting the percentage. Default is false. * - jump: boolean - If true, the video currentTime will jump directly to the specified percentage. If false, the change will be animated over time. * - transitionSpeed: number - Defines the speed of the transition when `jump` is false. Represents the duration of the transition in milliseconds. Default is 8. * - easing: (progress: number) => number - A function that defines the easing curve for the transition. It takes the progress ratio (a number between 0 and 1) as an argument and returns the eased value, affecting the playback speed during the transition. */ setVideoPercentage(percentage: number, options?: TransitionOptions): void; /** * Sets the style of the video or canvas to "cover" its container. * @param {HTMLElement | HTMLCanvasElement | undefined} el - The element to style. */ setCoverStyle(el: HTMLElement | HTMLCanvasElement | undefined): void; /** * Uses webCodecs to decode the video into frames. * @returns {Promise} Resolves when decoding is complete. */ decodeVideo(): Promise; /** * Paints the frame to the canvas. * @param {number} frameNum - The frame index to paint. */ paintCanvasFrame(frameNum: number): void; /** * Transitions the video or the canvas to the proper frame. * * @param options - Configuration options for adjusting the video playback. * - jump: boolean - If true, the video currentTime will jump directly to the specified percentage. If false, the change will be animated over time. * - transitionSpeed: number - Defines the speed of the transition when `jump` is false. Represents the duration of the transition in milliseconds. Default is 8. * - easing: (progress: number) => number - A function that defines the easing curve for the transition. It takes the progress ratio (a number between 0 and 1) as an argument and returns the eased value, affecting the playback speed during the transition. */ transitionToTargetTime({ jump, transitionSpeed, easing, }: TransitionOptions): void; /** * Sets the currentTime of the video as a specified percentage of its total duration. * * @param percentage - The percentage of the video duration to set as the current time. * @param options - Configuration options for adjusting the video playback. * - jump: boolean - If true, the video currentTime will jump directly to the specified percentage. If false, the change will be animated over time. * - transitionSpeed: number - Defines the speed of the transition when `jump` is false. Represents the duration of the transition in milliseconds. Default is 8. * - easing: (progress: number) => number - A function that defines the easing curve for the transition. It takes the progress ratio (a number between 0 and 1) as an argument and returns the eased value, affecting the playback speed during the transition. */ setTargetTimePercent(percentage: number, options?: TransitionOptions): void; /** * Simulate trackScroll programmatically (scrolls on page by percentage of video). * @param {number} percentage - The percentage of the video to scroll to. */ setScrollPercent(percentage: number): void; /** * Call to destroy this ScrollerVideo object. */ destroy(): void; /** * Autoplay the video by scrolling to the end. */ autoplayScroll(): void; /** * Updates debug information in the component state. */ updateDebugInfo(): void; } export default ScrollerVideo;