-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug fix for "ResizeObserver loop completed with undelivered notificat…
…ions." vuejs/vue-cli#7431 (comment)
- Loading branch information
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
course-react-ts-portfolio/jbook/src/resize-observer-bug-fix.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Taken from https://github.com/vuejs/vue-cli/issues/7431#issuecomment-1793385162 | ||
|
||
// Stop error resizeObserver | ||
const debounce = (callback: (...args: any[]) => void, delay: number) => { | ||
let tid: any; | ||
return function (...args: any[]) { | ||
// eslint-disable-next-line no-restricted-globals | ||
const ctx = self; | ||
tid && clearTimeout(tid); | ||
tid = setTimeout(() => { | ||
callback.apply(ctx, args); | ||
}, delay); | ||
}; | ||
}; | ||
|
||
const _ = (window as any).ResizeObserver; | ||
(window as any).ResizeObserver = class ResizeObserver extends _ { | ||
constructor(callback: (...args: any[]) => void) { | ||
callback = debounce(callback, 20); | ||
super(callback); | ||
} | ||
}; | ||
|
||
export {}; |