@numiko/dropdown-toggle
    Preparing search index...

    Class DropdownToggle

    Index

    Constructors

    Properties

    DURATION_DEFAULT: number = 0.3

    The default animation duration in seconds.

    Note: this will not apply if a custom animation is provided.

    DURATION_REDUCED_MOTION: number = 0.001

    The animation duration to use if a user has reduced motion enabled, in seconds.

    Note: this will not apply if a custom animation is provided.

    EASE_DEFAULT: string = 'power2.easeInOut'

    The default animation ease.

    See GSAP documentation for available easings: https://gsap.com/docs/v3/Eases/

    Note: this will not apply if a custom animation is provided.

    Methods

    • Parameters

      • instant: boolean = false

      Returns Promise<void>

    • Destroys the dropdown instance.

      This will:

      • Remove all event listeners
      • Immediately stop any animation on the dropdown item
      • Reset the markup to its initial state
      • Remove the instance from its group
      • Call the onDestroy callback

      Note: if you are using a custom animation, you may need to run additional cleanup code. This can be done by passing a custom onDestroy callback to the constructor.

      Returns void

    • Parameters

      • instant: boolean = false
      • bypassGroup: boolean = false

      Returns Promise<void>

    • Checks if all dropdowns in a given group are closed.

      Parameters

      • group: string

      Returns boolean

    • Checks if all dropdowns in a given group are open.

      Parameters

      • group: string

      Returns boolean

    • Parameters

      • group: string

      Returns Promise<void>

    Events

    GROUP_CHANGE_EVENT_NAME: "DropdownToggle:group-change" = 'DropdownToggle:group-change'

    The event that is emitted when a dropdown in a group is opened or closed.

    const dropdown = new DropdownToggle(button, {
    group: 'group-1',
    });

    window.addEventListener('DropdownToggle:group-change', (event: CustomEvent<GroupChangeEventDetail>) => {
    console.log(event.detail);
    });