UNPKG

tdesign-react

Version:
74 lines (73 loc) 2.53 kB
import { EasingFunction } from './easing'; import { ScrollContainer, ScrollContainerElement } from '../common'; export declare const canUseDocument: boolean; export declare const on: any; export declare const off: any; export declare function hasClass(el: Element, cls: string): boolean; export declare const addClass: (el: Element, cls: string) => void; export declare const removeClass: (el: Element, cls: string) => void; /** * 获取滚动容器 * 因为 document 不存在 scroll 等属性, 因此排除 document * window | HTMLElement * @param {ScrollContainerElement} [container='body'] * @returns {ScrollContainer} */ export declare const getScrollContainer: (container?: ScrollContainer) => ScrollContainerElement; type ScrollTarget = HTMLElement | Window | Document; /** * 获取滚动距离 * * @export * @param {ScrollTarget} target * @param {boolean} isLeft true 为获取 scrollLeft, false 为获取 scrollTop * @returns {number} */ export declare function getScroll(target: ScrollTarget, isLeft?: boolean): number; interface ScrollTopOptions { container?: ScrollTarget; duration?: number; easing?: EasingFunction; } export declare function scrollTo(target: number, opt: ScrollTopOptions): Promise<unknown>; export declare const isNodeOverflow: (ele: Element | Element[]) => boolean; export declare const getAttach: (node: any) => HTMLElement; export declare const getCssVarsValue: (name: string, element?: HTMLElement) => string; /** * 检查元素是否在父元素视图 * http://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport * @param elm 元素 * @param parent * @returns boolean */ export declare function elementInViewport(elm: HTMLElement, parent?: HTMLElement): boolean; /** * 获取元素某个 css 对应的值 * @param element 元素 * @param propName css 名 * @returns string */ export declare function getElmCssPropValue(element: HTMLElement, propName: string): string; /** * 判断元素是否处在 position fixed 中 * @param element 元素 * @returns boolean */ export declare function isFixed(element: HTMLElement): boolean; /** * 获取当前视图滑动的距离 * @returns { scrollTop: number, scrollLeft: number } */ export declare function getWindowScroll(): { scrollTop: number; scrollLeft: number; }; /** * 获取当前视图的大小 * @returns { width: number, height: number } */ export declare function getWindowSize(): { width: number; height: number; }; export {};