UNPKG

nhanh-pure-function

Version:
92 lines (91 loc) 4.13 kB
import { DragOption, LocalDragOptions, UiLibrary } from './type'; /** * 滚动结束监听器 * @param {(trigger: "vertical" | "horizontal") => void} callback */ export declare function _Element_ScrollEndListener(callback: (trigger: "vertical" | "horizontal") => void): (payload: Event) => void; /** * 点击非指定dom(包含子级dom)时执行 callback * @param querySelector 允许点击的 dom 顶层祖先元素选择器 * @param callback 满足条件时执行的回调 * * @param options 其他配置 * @param options.uiLibrary 项目使用的 ui库 , 用于排除 ui库 创建的元素 , 避免点击 ui库 创建的元素时意外的执行 callback * @param options.isClickAllowed 是否允许该点击 ( 如果不确定可以返回 undefined ) */ export declare function _Element_CloseOnOutsideClick(querySelector: string[], callback: Function, options?: { uiLibrary?: UiLibrary[]; isClickAllowed?: (event: MouseEvent) => boolean | undefined; }): void; /** 拖拽dom */ export declare class _Element_Drag { #private; init(dom: HTMLElement, option?: DragOption): void; finish(): void; bindOrUnbindEvent(type: "bind" | "unbind"): void; alterLocation(): void; mousedown(event: Event): void; mousemove(event: Event): void; mouseup(): void; } /** 局部拖拽 计算位置距离/百分比 */ export declare class _Element_LocalDrag { #private; init(parentDom: HTMLElement, options?: LocalDragOptions): void; finish(): void; bindOrUnbindEvent(type: "bind" | "unbind"): void; updateValue(): { top: number; left: number; percentage: { top: number; left: number; }; }; alterLocation(): void; mousedown(event: Event): void; mousemove(event: Event): void; mouseup(): void; } /** 进入全屏模式 */ export declare function _Element_EnterFullscreen(element?: HTMLElement | string): Promise<void>; /** 退出全屏模式 */ export declare function _Element_ExitFullscreen(): Promise<void>; /** 判断是否处于全屏模式 */ export declare function _Element_IsFullscreen(element?: HTMLElement | string): boolean; /** * 返回一个用于切换全屏模式的函数 * @param {HTMLElement} content - 需要进入全屏的元素 * 该函数通过检查不同浏览器的特定方法来实现全屏切换 */ export declare function _Element_Fullscreen(element?: HTMLElement | string): () => void; /** * 元素全屏状态观察器 * 监听元素的全屏状态变化,并通过回调函数通知状态改变 * @param notify - 全屏状态变化回调函数,接收一个布尔值参数表示当前是否为全屏状态 * @param selectors - 要观察的元素或元素选择器,默认为document.documentElement * @returns 返回一个清理函数,调用后可移除所有事件监听器 */ export declare function _Element_FullscreenObserver(notify: (isFull: boolean) => void, selectors?: HTMLElement | string): () => void; /** * 单位转换 12** -> **px * @param {string} width * @returns 对应的单位为px的宽 */ export declare function _Element_GetOtherSizeInPixels(width: string, target?: HTMLElement): number; /** * 根据给定的宽高比和目标元素或尺寸,计算画布的尺寸 * 此函数旨在适应不同场景下,如何根据宽高比约束,计算出适合的画布大小 * * @param aspectRatio 宽高比,表示期望的画布宽度与高度的比例 * @param target 目标元素或尺寸,可以是DOM元素、选择器字符串或尺寸数组 * @returns 返回计算后的画布尺寸,格式为[宽度, 高度] */ export declare function _Element_CalculateCanvasSize(aspectRatio: number, target: Element | string | [number, number]): number[] | undefined; /** * 异步加载图片,并返回图片对象及其宽高比 * @param src 图片的URL地址 * @param timeout 超时时间,单位为毫秒,默认为5000ms * @returns 一个Promise对象,包含加载的图片对象及其宽高比 */ export declare function _Element_LoadImage(src: string, timeout?: number): Promise<[HTMLImageElement, number]>;