export interface Uni { /** * 创建并返回一个 IntersectionObserver 对象实例 * * @tutorial https://uniapp.dcloud.net.cn/api/ui/intersection-observer.html#createintersectionobserver * @tutorial-uni-app https://uniapp.dcloud.net.cn/api/ui/intersection-observer.html#createintersectionobserver * @uniPlatform { * "app": { * "android": { * "osVer": "5.0", * "uniVer": "√", * "unixVer": "x" * }, * "ios": { * "osVer": "12.0", * "uniVer": "√", * "unixVer": "x" * }, * "harmony": { * "osVer": "3.0", * "uniVer": "4.23", * "unixVer": "x" * } * }, * "mp": { * "weixin": { * "hostVer": "√", * "uniVer": "√", * "unixVer": "x" * }, * "alipay": { * "hostVer": "√", * "uniVer": "√", * "unixVer": "x" * }, * "baidu": { * "hostVer": "√", * "uniVer": "√", * "unixVer": "x" * }, * "toutiao": { * "hostVer": "√", * "uniVer": "√", * "unixVer": "x" * }, * "lark": { * "hostVer": "√", * "uniVer": "√", * "unixVer": "x" * }, * "qq": { * "hostVer": "√", * "uniVer": "√", * "unixVer": "x" * }, * "kuaishou": { * "hostVer": "√", * "uniVer": "√", * "unixVer": "x" * }, * "jd": { * "hostVer": "√", * "uniVer": "√", * "unixVer": "x" * } * }, * "web": { * "uniVer": "√", * "unixVer": "4.0" * } * } */ createIntersectionObserver: CreateIntersectionObserver; } export type CreateIntersectionObserver = (component: any, options: CreateIntersectionObserverOptions) => IntersectionObserver; export interface CreateIntersectionObserverOptions { /** * 所有阈值 */ thresholds?: (any[]) | null, /** * 初始的相交比例 */ initialRatio?: number | null, /** * 是否同时观测多个参照节点(而非一个) */ observeAll?: boolean | null }; export type ObserveNodeRect = { /** * left */ left: number, /** * right */ right: number, /** * top */ top: number, /** * bottom */ bottom: number }; export type ObserveResult = { /** * 相交比例 */ intersectionRatio: number, /** * 相交区域的边界 */ intersectionRect: any, /** * 目标节点布局区域的边界 */ boundingClientRect: ObserveNodeRect, /** * 参照区域的边界 */ relativeRect: ObserveNodeRect, /** * 相交检测时的时间戳 */ time: number }; export type ObserveCallback = (result: ObserveResult) => void; export interface IntersectionObserver { /** * 使用选择器指定一个节点,作为参照区域之一 */ relativeTo(selector: string, margins?: any): IntersectionObserver; /** * 指定页面显示区域作为参照区域之一 */ relativeToViewport(margins?: any): IntersectionObserver; /** * 指定目标节点并开始监听相交状态变化情况 */ observe(targetSelector: string, callback: ObserveCallback): void; /** * 停止监听 */ disconnect(): void; }