Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<doc>: 全局水印与其它遮罩层冲突 [issue 129] #136

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,18 @@ export class Watermark {

if (MutationObserver && this.options.monitor) {
this.mutationObserver = new MutationObserver(mutations => {
// 避免多次执行render函数,导致多次注册MutationObserver 从而进入死循环逻辑
let lastMoutation;
mutations.forEach(mutation => {
if (this._isAgainRender(mutation)) {
this.destroy();
this._render();
lastMoutation = mutation;
return;
}
});
if(lastMoutation){
this.destroy();
this._render();
}
});
this.mutationObserver.observe(this.container, observeOptions);
this.shadowRoot && this.mutationObserver.observe(this.shadowRoot, observeOptions);
Expand Down