@gdjiami/hooks
Version:
react hooks for mygzb.com
39 lines (38 loc) • 1.21 kB
TypeScript
import { RefObject } from 'react';
import { GestureCoordinate, MultiTouchGesture } from './useMultiTouchGesture';
export { GestureCoordinate };
export interface Coord {
x: number;
y: number;
}
export declare enum SwipeDirection {
Up = "up",
Down = "down",
Left = "left",
Right = "right"
}
export interface UseTouchOption<T extends HTMLElement> {
onDown?: (info: MultiTouchGesture) => void;
onMove?: (info: MultiTouchGesture) => void;
onUp?: (info: MultiTouchGesture) => void;
onTap?: (info: GestureCoordinate) => void;
onSingleTap?: (info: GestureCoordinate) => void;
onDoubleTap?: (info: GestureCoordinate) => void;
onLongTap?: (info: GestureCoordinate) => void;
onRotate?: (info: {
angle: number;
}) => void;
onPinch?: (info: {
center: Coord;
scale: number;
}) => void;
onSwipe?: (info: {
direction: SwipeDirection;
distance: number;
}) => void;
onPressMove?: (info: GestureCoordinate) => void;
ref?: RefObject<T>;
}
export default function useTouch<T extends HTMLElement = HTMLDivElement>(options: UseTouchOption<T>): {
ref: RefObject<T>;
};