/*! * Cuberto Mouse Follower * https://cuberto.com/ * * @version 1.2.1 * @author Cuberto, Artem Dordzhiev (Draft) */ export default class MouseFollower { /** * @typedef {Object} MouseFollowerOptions * @property {string|HTMLElement|null} [el] Existing cursor element, created automatically if not specified. * @property {string|HTMLElement|null} [container] Cursor container. Body by default. * @property {string|HTMLElement|null} [eventsTarget] Target for cursor events. Root document element by default. * @property {string} [className] Cursor root element class name. * @property {string} [innerClassName] Inner element class name. * @property {string} [textClassName] Text element class name. * @property {string} [mediaClassName] Media element class name. * @property {string} [mediaBoxClassName] Media inner element class name. * @property {string} [iconSvgClassName] SVG sprite class name. * @property {string} [iconSvgNamePrefix] SVG sprite class name prefix for icons. * @property {string} [iconSvgSrc] SVG sprite source. If you are not using SVG sprites, leave this blank. * @property {string} [iconImgClassName] SVG icon img class name. * @property {string|null} [dataAttr] Data attribute name for changing cursor state in HTML. Uses event delegation. * @property {string} [hiddenState] Hidden class name state. * @property {string} [textState] Text class name state. * @property {string} [iconState] Icon class name state. * @property {string|null} [activeState] Active (mousedown) class name state. Set `false` to disable. * @property {string} [mediaState] Media (image/video) class name state. * @property {Object} [stateDetection] Predefined states for different page elements. Uses event delegation. * @property {boolean} [visible] Whether the cursor is visible by default. * @property {boolean} [visibleOnState] Automatically show/hide cursor when a state is added. * @property {number} [speed] Cursor movement speed. * @property {string} [ease] Timing function of cursor movement. See GSAP easing. * @property {boolean} [overwrite] Overwrite or preserve the cursor position when `mousemove` fires. * @property {number} [skewing] Default "skewing" factor. * @property {number} [skewingText] Skew effect factor in the text state. Set `0` to disable skew in this mode. * @property {number} [skewingIcon] Skew effect factor in the icon state. Set `0` to disable skew in this mode. * @property {number} [skewingMedia] Skew effect factor in the media state. Set `0` to disable. * @property {number} [skewingDelta] Skew effect base delta. * @property {number} [skewingDeltaMax] Skew effect max delta. * @property {number} [stickDelta] Stick effect delta. * @property {number} [showTimeout] Delay before showing. May be useful for the spawn animation to work properly. * @property {boolean} [hideOnLeave] Hide the cursor when the mouse leaves the event target. * @property {number} [hideTimeout] Hiding delay. Should be equal to the CSS hide animation time. * @property {number[]} [initialPos] Array (x, y) of the initial cursor position. */ /** * Register the GSAP animation library. * * @param {gsap} gsap GSAP library. */ static registerGSAP(gsap: any): void; /** * Create a cursor instance. * * @param {MouseFollowerOptions} [options] Cursor options. */ constructor(options?: { /** * Existing cursor element, created automatically if not specified. */ el?: string | HTMLElement | null; /** * Cursor container. Body by default. */ container?: string | HTMLElement | null; /** * Target for cursor events. Root document element by default. */ eventsTarget?: string | HTMLElement | null; /** * Cursor root element class name. */ className?: string; /** * Inner element class name. */ innerClassName?: string; /** * Text element class name. */ textClassName?: string; /** * Media element class name. */ mediaClassName?: string; /** * Media inner element class name. */ mediaBoxClassName?: string; /** * SVG sprite class name. */ iconSvgClassName?: string; /** * SVG sprite class name prefix for icons. */ iconSvgNamePrefix?: string; /** * SVG sprite source. If you are not using SVG sprites, leave this blank. */ iconSvgSrc?: string; /** * SVG icon img class name. */ iconImgClassName?: string; /** * Data attribute name for changing cursor state in HTML. Uses event delegation. */ dataAttr?: string | null; /** * Hidden class name state. */ hiddenState?: string; /** * Text class name state. */ textState?: string; /** * Icon class name state. */ iconState?: string; /** * Active (mousedown) class name state. Set `false` to disable. */ activeState?: string | null; /** * Media (image/video) class name state. */ mediaState?: string; /** * Predefined states for different page elements. Uses event delegation. */ stateDetection?: any; /** * Whether the cursor is visible by default. */ visible?: boolean; /** * Automatically show/hide cursor when a state is added. */ visibleOnState?: boolean; /** * Cursor movement speed. */ speed?: number; /** * Timing function of cursor movement. See GSAP easing. */ ease?: string; /** * Overwrite or preserve the cursor position when `mousemove` fires. */ overwrite?: boolean; /** * Default "skewing" factor. */ skewing?: number; /** * Skew effect factor in the text state. Set `0` to disable skew in this mode. */ skewingText?: number; /** * Skew effect factor in the icon state. Set `0` to disable skew in this mode. */ skewingIcon?: number; /** * Skew effect factor in the media state. Set `0` to disable. */ skewingMedia?: number; /** * Skew effect base delta. */ skewingDelta?: number; /** * Skew effect max delta. */ skewingDeltaMax?: number; /** * Stick effect delta. */ stickDelta?: number; /** * Delay before showing. May be useful for the spawn animation to work properly. */ showTimeout?: number; /** * Hide the cursor when the mouse leaves the event target. */ hideOnLeave?: boolean; /** * Hiding delay. Should be equal to the CSS hide animation time. */ hideTimeout?: number; /** * Array (x, y) of the initial cursor position. */ initialPos?: number[]; }); /** @type {MouseFollowerOptions} **/ options: { /** * Existing cursor element, created automatically if not specified. */ el?: string | HTMLElement | null; /** * Cursor container. Body by default. */ container?: string | HTMLElement | null; /** * Target for cursor events. Root document element by default. */ eventsTarget?: string | HTMLElement | null; /** * Cursor root element class name. */ className?: string; /** * Inner element class name. */ innerClassName?: string; /** * Text element class name. */ textClassName?: string; /** * Media element class name. */ mediaClassName?: string; /** * Media inner element class name. */ mediaBoxClassName?: string; /** * SVG sprite class name. */ iconSvgClassName?: string; /** * SVG sprite class name prefix for icons. */ iconSvgNamePrefix?: string; /** * SVG sprite source. If you are not using SVG sprites, leave this blank. */ iconSvgSrc?: string; /** * SVG icon img class name. */ iconImgClassName?: string; /** * Data attribute name for changing cursor state in HTML. Uses event delegation. */ dataAttr?: string | null; /** * Hidden class name state. */ hiddenState?: string; /** * Text class name state. */ textState?: string; /** * Icon class name state. */ iconState?: string; /** * Active (mousedown) class name state. Set `false` to disable. */ activeState?: string | null; /** * Media (image/video) class name state. */ mediaState?: string; /** * Predefined states for different page elements. Uses event delegation. */ stateDetection?: any; /** * Whether the cursor is visible by default. */ visible?: boolean; /** * Automatically show/hide cursor when a state is added. */ visibleOnState?: boolean; /** * Cursor movement speed. */ speed?: number; /** * Timing function of cursor movement. See GSAP easing. */ ease?: string; /** * Overwrite or preserve the cursor position when `mousemove` fires. */ overwrite?: boolean; /** * Default "skewing" factor. */ skewing?: number; /** * Skew effect factor in the text state. Set `0` to disable skew in this mode. */ skewingText?: number; /** * Skew effect factor in the icon state. Set `0` to disable skew in this mode. */ skewingIcon?: number; /** * Skew effect factor in the media state. Set `0` to disable. */ skewingMedia?: number; /** * Skew effect base delta. */ skewingDelta?: number; /** * Skew effect max delta. */ skewingDeltaMax?: number; /** * Stick effect delta. */ stickDelta?: number; /** * Delay before showing. May be useful for the spawn animation to work properly. */ showTimeout?: number; /** * Hide the cursor when the mouse leaves the event target. */ hideOnLeave?: boolean; /** * Hiding delay. Should be equal to the CSS hide animation time. */ hideTimeout?: number; /** * Array (x, y) of the initial cursor position. */ initialPos?: number[]; }; gsap: any; el: Element; container: Element; eventsTarget: Element; skewing: number; pos: { x: number; y: number; }; vel: { x: number; y: number; }; event: {}; events: any[]; /** * Initialize the cursor. */ init(): void; ticker: any; /** * Create cursor DOM elements or get existing ones. */ create(): void; inner: HTMLElement; media: HTMLElement; mediaBox: HTMLElement; text: HTMLElement; /** * Create a cursor DOM part or get an existing one. * * @param {string} className Element class name. * @param {HTMLElement} container Parent element. * @param {boolean} [reuse=true] Use existing element if found. * @return {HTMLElement} Cursor DOM part. */ createPart(className: string, container: HTMLElement, reuse?: boolean): HTMLElement; /** * Create the GSAP setters. */ createSetter(): void; setter: { x: any; y: any; rotation: any; scaleX: any; scaleY: any; wc: any; inner: { rotation: any; }; }; /** * Create and attach event listeners. */ bind(): void; /** * Render the cursor at a new position. * * @param {boolean} [force=false] Force rendering. */ render(force?: boolean): void; /** * Show the cursor. */ show(): void; visibleInt: NodeJS.Timeout; visible: boolean; /** * Hide the cursor. */ hide(): void; /** * Toggle the cursor. * * @param {boolean} [force] Force the visibility state. */ toggle(force?: boolean): void; /** * Add one or more states to the cursor. * * @param {string} state State name. */ addState(state: string): void; /** * Remove one or more states from the cursor. * * @param {string} state State name. */ removeState(state: string): void; /** * Toggle the cursor state. * * @param {string} state State name. * @param {boolean} [force] Force the state. */ toggleState(state: string, force?: boolean): void; /** * Set the skewing effect factor. * * @param {number} value Skewing factor. */ setSkewing(value: number): void; /** * Revert the skewing factor to the default. */ removeSkewing(): void; /** * Stick the cursor to an element. * * @param {string|HTMLElement} element Element or selector. */ setStick(element: string | HTMLElement): void; stick: boolean | { y: number; x: number; }; /** * Unstick the cursor from the element. */ removeStick(): void; /** * Transform the cursor to text mode with the given string. * * @param {string} text Text. */ setText(text: string): void; /** * Revert the cursor from text mode. */ removeText(): void; /** * Transform the cursor to SVG icon mode. * * @param {string|SVGElement} icon Icon identifier or SVG element. * @param {string} [style=""] Additional SVG styles. */ setIcon(icon: string | SVGElement, style?: string): void; /** * Transform the cursor to image icon mode. * * @param {string} url Icon URL. * @param {string} [style=""] Additional img styles. */ setIconImg(url: string, style?: string): void; /** * Revert the cursor from icon mode. */ removeIcon(): void; /** * Transform the cursor to media mode with the given element. * * @param {HTMLElement} element Element. */ setMedia(element: HTMLElement): void; mediaInt: NodeJS.Timeout; /** * Revert the cursor from media mode. */ removeMedia(): void; /** * Transform the cursor to image mode. * * @param {string} url Image URL. */ setImg(url: string): void; mediaImg: HTMLImageElement; /** * Revert the cursor from image mode. */ removeImg(): void; /** * Transform the cursor to video mode. * * @param {string} url Video URL. */ setVideo(url: string): void; mediaVideo: HTMLVideoElement; /** * Revert the cursor from video mode. */ removeVideo(): void; /** * Attach an event handler. * * @param {string} event Event name. * @param {function} callback Callback function. */ on(event: string, callback: Function): void; /** * Remove an event handler. * * @param {string} event Event name. * @param {function} [callback] Callback function. */ off(event: string, callback?: Function): void; /** * Execute all handlers for the given event type. * * @param {string} event Event name. * @param {...*} params Extra parameters. */ trigger(event: string, ...params: any[]): void; /** * Get cursor options from the data attributes of a given element. * * @param {HTMLElement} element Element. * @return {Object} Options. */ getFromDataset(element: HTMLElement): any; /** * Destroy the cursor instance. */ destroy(): void; } //# sourceMappingURL=index.d.ts.map