/** * @file DOM 元素或 DOM 事件相关的 hooks */ import { useSize as useSizeOriginal, useInViewport as useInViewportOriginal, useEventListener as useEventListenerOriginal, useDocumentVisibility as useDocumentVisibilityOriginal, useKeyPress as useKeyPressOriginal } from 'ahooks'; import { TouchEvent } from 'react'; import { useSwipeable } from 'react-swipeable'; /** * 一个用于判断 dom 元素是否在可视范围之内的 hook. * 文档:https://ahooks.js.org/hooks/dom/use-in-viewport/ */ export declare const useInViewport: typeof useInViewportOriginal; /** * 一个用于获取 dom 元素大小的 hook. * 文档: https://ahooks.js.org/hooks/dom/use-size/ */ export declare const useSize: typeof useSizeOriginal; /** * 监听事件 Hook * 文档: https://ahooks.js.org/hooks/dom/use-event-listener */ export declare const useEventListener: typeof useEventListenerOriginal; /** * 检查页面是否可见 * 文档: https://ahooks.js.org/hooks/dom/use-document-visibility */ export declare const useDocumentVisibility: typeof useDocumentVisibilityOriginal; /** * 监听 window.resize 事件, 并可为事件的回调函数设定 throttle 的间隔 * * @param handler - 回调函数 * @param wait - throttle 的间隔, 默认 50ms */ export declare const useOnResize: (handler: () => void, wait?: number) => void; /** * 监听键盘事件 Hook * 文档: https://ahooks.js.org/hooks/dom/use-key-press */ export declare const useKeyPress: typeof useKeyPressOriginal; /** * **重新**聚焦页面时调用函数 * 通常的使用场景为: * 当在页面 A 进行查看或编辑时,需要跳转到页面 B 去完成某个 A 的子内容的编辑,同时在编辑 B 完成后,返回 A 时,需要同步 B 处修改的场景。 * 此时使用该 Hook 检测与更新数据 * * @param handler - handler */ export declare function useDocumentRefocused(handler: Function): void; /** * 在组件初次挂载 (mount) 时自动聚焦指定元素 * * @returns 返回[应赋给目标元素的 ref, 手动 focus 元素的方法] */ export declare const useAutofocusRef: () => readonly [import("react").MutableRefObject, () => void]; /** * 监听指定元素的左划/右划/上划/下划事件 (主要用于 web 移动端) * * 文档见: https://github.com/FormidableLabs/react-swipeable. * 一般需要根据实际需求调校 delta 参数 (即滑动多少距离生效) * * @example * ```javascript * const handlers = useSwipeable({ * onSwiped: (eventData) => console.log('Swiped!', eventData), * ...config, * }) * return
Swipe here
* ``` */ export declare const useOnSwipe: typeof useSwipeable; /** * 监听指定元素的长按事件 (基于 touch 事件, 只支持移动端) * * @param callback - 回调函数 * @param duration - 要求长按多久? 默认 500ms * @param stopPropagation - 是否阻止事件冒泡 * * @returns 返回应赋给目标元素的 ref * * @example * ```javascript * const ref = useOnLongPressRef(ev => { * console.log('Long pressed', ev) * }) * * return
Long Press Me
* ``` */ export declare const useOnLongPressRef: (callback?: ((ev: TouchEvent) => void) | undefined, { duration, stopPropagation, }?: { duration?: number | undefined; stopPropagation?: boolean | undefined; }) => import("react").RefObject;