saltfish
Version:
An interactive video-guided tour system for web applications
190 lines • 6.11 kB
TypeScript
import type { CursorAnimation } from '../types';
/**
* Manager class for handling virtual cursor animations and flashlight effect
*/
export declare class CursorManager {
private cursor;
private animationFrameId;
private animationStartTime;
private currentAnimation;
private flashlightOverlay;
private startX;
private startY;
private targetX;
private targetY;
private shouldShowCursor;
private lastCursorX;
private lastCursorY;
private isFirstAnimation;
private currentTargetElement;
private scrollThrottleTimeout;
private boundScrollHandler;
private scrollableParents;
private parentScrollHandlers;
private selectionElement;
private isSelectionMode;
private selectionStartWidth;
private selectionStartHeight;
private selectionTargetWidth;
private selectionTargetHeight;
private selectionPadding;
private dragStartX;
private dragStartY;
private dragEndX;
private dragEndY;
private dragPhase;
private dragAnimationStartTime;
private cursorSpeed;
private totalDistance;
private controlPointX;
private controlPointY;
private targetMutationObserver;
/**
* Finds all scrollable parent containers of an element
* @param element - The element to find scrollable parents for
* @returns Array of scrollable parent elements
*/
private findScrollableParents;
/**
* Adds scroll event listeners to scrollable parent containers
* @param element - The target element whose parents should be monitored
*/
private addScrollListenersToParents;
/**
* Removes scroll event listeners from all tracked parent containers
*/
private removeScrollListenersFromParents;
/**
* Helper function to find an element in the document
* @param selector - CSS selector
* @returns - The found element or null
*/
private findElement;
/**
* Checks if an element is completely visible in the viewport and within all scrollable parent containers
* @param element - The element to check
* @returns - Whether the entire element is visible in viewport and all scrollable parents
*/
private isElementInViewport;
/**
* Scrolls an element into view smoothly, handling both window and parent container scrolling
* @param element - The element to scroll into view
* @returns - Promise that resolves when scrolling is complete
*/
private scrollElementIntoView;
/**
* Scrolls parent containers to make the element visible
* @param element - The target element
* @param scrollableParents - Array of scrollable parent containers
* @returns Promise that resolves when scrolling is complete
*/
private scrollParentContainersToShowElement;
/**
* Finds an element and scrolls it into view if necessary
* @param selector - CSS selector
* @returns - Promise that resolves with the element or null
*/
private findElementAndScrollIntoView;
/**
* Creates the virtual cursor element
*/
create(): void;
/**
* Handles scrolling to keep the cursor positioned on the target element
*/
private handleScroll;
/**
* Checks if autoplay is blocked and cursor should be disabled
* @returns - Whether autoplay is blocked
*/
private isAutoplayBlocked;
/**
* Sets whether the cursor should be shown based on step configuration
* @param shouldShow - Whether the cursor should be shown
*/
setShouldShowCursor(shouldShow: boolean): void;
/**
* Shows the cursor and flashlight at a specific position
* Note: Will only show if shouldShowCursor is true and autoplay is not blocked
* @param x - X coordinate
* @param y - Y coordinate
*/
show(x: number, y: number): void;
/**
* Hides the cursor and flashlight
* @deprecated Use setShouldShowCursor(false) instead for better state management
*/
hide(): void;
/**
* Resets the flashlight overlay to its original state without cutouts
*/
private resetFlashlightOverlay;
/**
* Updates the selection area position and size
* @param targetElement - Element to select
* @param styles - Optional selection styles
*/
private updateSelectionArea;
/**
* Animates the cursor along a path
* @param animation - Animation configuration
*/
animate(animation: CursorAnimation): Promise<void>;
/**
* Handles selection mode setup and animation
*/
private handleSelectionMode;
/**
* Animation frame handler for drag selection
*/
private dragAnimationFrame;
/**
* Updates the flashlight overlay to exclude the selection area
*/
private updateFlashlightWithCutout;
/**
* Calculates a control point for curved cursor movement
*/
private calculateControlPoint;
/**
* Moves the cursor to a DOM element
* @param selector - DOM element selector
* @param mode - Optional mode for cursor (pointer or selection)
* @param selectionStyles - Optional styles for selection mode
*/
moveToElement(selector: string, mode?: 'pointer' | 'selection', selectionStyles?: CursorAnimation['selectionStyles']): Promise<void>;
/**
* Simulates a click action with the cursor
*/
click(): void;
/**
* Stops the current animation
*/
stopAnimation(): void;
/**
* Gets the current X position of the cursor
*/
getCursorX(): number;
/**
* Gets the current Y position of the cursor
*/
getCursorY(): number;
/**
* Resets cursor state for first animation
*/
resetFirstAnimation(): void;
/**
* Cleans up resources used by the cursor manager
*/
destroy(): void;
/**
* Animation frame handler
*/
private animationFrame;
/**
* Sets the color of the cursor SVG
* @param color - The color to set (hex, rgb, etc)
*/
setColor(color: string): void;
}
//# sourceMappingURL=CursorManager.d.ts.map