Skip to content

Commit

Permalink
fix: Avoid triggering ResizeObserver handler loop when changing conta…
Browse files Browse the repository at this point in the history
…iner height
  • Loading branch information
null0rUndefined authored and anthony-redFox committed Dec 5, 2023
1 parent 974a872 commit 2f75b8c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/GridLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,14 @@ export default class GridLayout extends HTMLElement {
declare placeholder: HTMLElement;
template = template;
sheet = new CSSStyleSheet();
#timeout?: number;
observer = new ResizeObserver(() => {
this.calculateSize();
this.render();
clearTimeout(this.#timeout);
this.#timeout = setTimeout(() => {
this.#timeout = void 0;
this.calculateSize();
this.render();
}, 250);
});
breakpoints = { lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0 };
colsAdaptation = { lg: 12, md: 10, sm: 6, xs: 4, xxs: 2 };
Expand Down

0 comments on commit 2f75b8c

Please sign in to comment.