Class CustomCursor<StaticProps, ChangeableProps, CallbacksTypes>

Creates a smooth custom cursor that replaces the native cursor and follows mouse movements with smoothing and animations. The cursor's appearance and behavior can be customized, and it supports interacting with hoverable elements.

Requires

Requires styles: @import '~vevet/lib/styles/components/CustomCursor';

Link

See examples https://antonbobrov.github.io/vevet-demo/custom-cursor/

Link

See docs https://antonbobrov.github.io/vevet/classes/CustomCursor.html

Type Parameters

Hierarchy

  • Component<StaticProps, ChangeableProps, CallbacksTypes>
    • CustomCursor

Constructors

Accessors

  • get innerElement(): HTMLElement
  • The inner element of the custom cursor. This element is nested inside the outer element and can provide additional styling.

    Returns HTMLElement

  • get isCoordsInterpolated(): boolean
  • Checks if all coordinates are interpolated.

    Returns boolean

    True if all coordinates are interpolated, false otherwise.

  • get isDestroyed(): boolean
  • Checks if the module has been destroyed.

    Returns boolean

  • get isInitialized(): boolean
  • Checks if the module has been initialized.

    Returns boolean

  • get name(): string
  • The name of the module, derived from the class name

    Returns string

  • get outerElement(): HTMLElement
  • The outer element of the custom cursor. This is the visual element that represents the cursor on screen.

    Returns HTMLElement

  • get props(): TRequiredModuleProp<StaticProps & ChangeableProps>
  • The current properties of the module, which include both static and changeable properties. These can be retrieved dynamically during the module's lifecycle.

    Returns TRequiredModuleProp<StaticProps & ChangeableProps>

  • get targetCoords(): {
        height: number;
        width: number;
        x: number;
        y: number;
    }
  • Target coordinates of the cursor for interpolation.

    Returns {
        height: number;
        width: number;
        x: number;
        y: number;
    }

    • height: number
    • width: number
    • x: number
    • y: number

Methods

  • Adds a custom callback to the module.

    Type Parameters

    • T extends string | number | symbol

    Parameters

    • target: T

      The event type to listen for (e.g., 'propsChange', 'destroy').

    • action: TAction<CallbacksTypes[T]>

      The function to execute when the event is triggered.

    • settings: ISettings = {}

      Additional settings for the callback.

    Returns IAddedCallback

  • Adds a DOM event listener that will be automatically removed when the module is destroyed.

    Type Parameters

    • Target extends keyof HTMLElementEventMap

    • Listener extends ((event) => void)

    Parameters

    • element: Document | Element | Window

      The target element for the event listener.

    • target: Target

      The event type to listen for (e.g., 'click', 'resize').

    • callback: Listener

      The callback function to execute when the event is triggered.

    • Optional options: boolean | AddEventListenerOptions

      Additional options for the event listener.

    Returns (() => void)

      • (): void
      • Returns void

  • Sets hover events on an element.

    Parameters

    • settingsProp: IHoveredElement

      The settings for the hovered element.

    • Optional enterTimeout: number = 100

      The timeout before the hover effect is applied.

    Returns {
        remove: (() => void);
    }

    An object containing a remove method to unregister the hover events.

    • remove: (() => void)
        • (): void
        • Returns void

  • Adds a plugin to the component. The plugin is initialized upon being added, and the plugin's component property is set to the current component instance.

    Type Parameters

    • T extends Plugin<any, any, any, any>

    Parameters

    • plugin: T

      An instance of the Plugin class to be added.

    Returns void

  • Adds a viewport callback that will be automatically removed when the module is destroyed.

    Parameters

    • target: keyof IViewportCallbackTypes

      The viewport target (e.g., width or height).

    • action: (() => void)

      The callback function to execute when the viewport target changes.

        • (): void
        • Returns void

    • data: undefined | ISettings = {}

      Additional data for the callback.

    Returns void