Skip to content

Commit

Permalink
fix: prevent error "ResizeObserver loop completed with undelivered no…
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-sc committed Sep 10, 2024
1 parent 369359c commit 6cdd428
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions projects/ngx-scrollbar/src/lib/viewport/observer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ export function resizeObserver({ element, contentWrapper, throttleDuration }: Re

const stream: Observable<ScrollbarUpdateReason> = new Observable((observer: Observer<ScrollbarUpdateReason>) => {
resizeObserver = new ResizeObserver(() => {
observer.next(reason);
// After first init event, mark the reason to be a resize from now on.
reason = ScrollbarUpdateReason.Resized;
requestAnimationFrame(() => {
observer.next(reason);
// After first init event, mark the reason to be a resize from now on.
reason = ScrollbarUpdateReason.Resized;
});
});
resizeObserver.observe(element);

Expand Down

0 comments on commit 6cdd428

Please sign in to comment.