Skip to content

Commit

Permalink
fix: unobserve removed panel when panel change
Browse files Browse the repository at this point in the history
  • Loading branch information
malangfox committed Aug 23, 2024
1 parent a4761b8 commit 3763e79
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/core/AutoResizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ class AutoResizer {
return this;
}

public unobserve(element: Element): this {
if (this._resizeObserver) {
this._resizeObserver.unobserve(element);
}
return this;
}

private _onResize = () => {
const flicking = this._flicking;
const resizeDebounce = flicking.resizeDebounce;
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/Renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,9 @@ abstract class Renderer {
panelsAdded.forEach((panel) => {
flicking.autoResizer.observe(panel.element);
});
panelsRemoved.forEach((panel) => {
flicking.autoResizer.unobserve(panel.element);
});
}

void this.render();
Expand Down

0 comments on commit 3763e79

Please sign in to comment.