@types/subscribe-ui-event
TypeScript icon, indicating that this package has built-in type declarations

1.1.8 • Public • Published

Installation

npm install --save @types/subscribe-ui-event

Summary

This package contains type definitions for subscribe-ui-event (https://github.com/yahoo/subscribe-ui-event#readme).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/subscribe-ui-event.

index.d.ts

export type UIEventType =
    | "resize"
    | "resizeEnd"
    | "resizeStart"
    | "scroll"
    | "scrollEnd"
    | "scrollStart"
    | "visibilitychange";

export type TouchEventType =
    | "touchend"
    | "touchmove"
    | "touchmoveEnd"
    | "touchmoveStart"
    | "touchstart";

export type EventType = UIEventType | TouchEventType;

export interface SubscribeOptions {
    context?: any;
    enableResizeInfo?: boolean | undefined;
    enableScrollInfo?: boolean | undefined;
    enableTouchInfo?: boolean | undefined;
    eventOptions?: AddEventListenerOptions | undefined;
    target?: HTMLElement | Window | Document | null;
    throttleRate?: number | undefined;
    useRAF?: boolean | undefined;
}

export interface ArgmentedEvent<T extends EventType> {
    mainType: string;
    resize: {
        height: number;
        width: number;
    };
    scroll: {
        delta: number;
        top: number;
    };
    subType: string;
    type: T;
    touch: {
        axisIntention: "x" | "y" | "";
        deltaX: number;
        deltaY: number;
        startX: number;
        startY: number;
    };
}

export type UIEventCallback<T extends UIEventType = UIEventType> = (
    event: UIEvent,
    payload: ArgmentedEvent<T>,
) => any;

export type TouchEventCallback<T extends TouchEventType = TouchEventType> = (
    event: TouchEvent,
    payload: ArgmentedEvent<T>,
) => any;

export interface Subscription {
    unsubscribe: () => void;
}

export function subscribe<T extends UIEventType>(
    eventType: T,
    callback: UIEventCallback<T>,
    options?: SubscribeOptions,
): Subscription;

export function subscribe<T extends TouchEventType>(
    eventType: T,
    callback: TouchEventCallback<T>,
    options?: SubscribeOptions,
): Subscription;

export function unsubscribe<T extends UIEventType>(
    eventType: T,
    callback: UIEventCallback<T>,
): void;

export function unsubscribe<T extends TouchEventType>(
    eventType: T,
    callback: TouchEventCallback<T>,
): void;

export function listen(
    target: EventTarget,
    eventType: string,
    handler: EventListenerOrEventListenerObject,
    options?: AddEventListenerOptions,
): {
    remove: () => void;
};

Additional Details

  • Last updated: Tue, 07 Nov 2023 15:11:36 GMT
  • Dependencies: none

Credits

These definitions were written by .

Readme

Keywords

none

Package Sidebar

Install

npm i @types/subscribe-ui-event

Weekly Downloads

3,296

Version

1.1.8

License

MIT

Unpacked Size

6.81 kB

Total Files

5

Last publish

Collaborators

  • types