You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.2 KiB
Plaintext

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/**
* @description 封装 MutationObserver
* @author fangzhicong
*/
export declare type callback = (mutations: MutationRecord[], observer: Mutation) => void;
/**
* 封装 MutationObserver抽离成公共类
*/
export default class Mutation {
/**
* MutationObserver 实例
*/
protected observer: MutationObserver;
/**
* 被监听的 Node 节点(可继承的,方便扩展但又不会在外部被修改)
*/
protected node?: Node;
/**
* 默认的 MutationObserverInit 配置
*/
protected options: MutationObserverInit;
/**
* MutationCallback
*/
protected callback: (mutations: MutationRecord[]) => void;
/**
* 构造器
* @param fn 发生变化时执行的回调函数
* @param options 自定义配置项
*/
constructor(fn: callback, options?: MutationObserverInit);
get target(): Node | undefined;
/**
* 绑定监听节点(初次绑定有效)
* @param node 需要被监听的节点
*/
observe(node: Node): void;
/**
* 连接监听器(开始观察)
*/
connect(): this;
/**
* 断开监听器(停止观察)
*/
disconnect(): void;
}