Skip to content

Commit

Permalink
Merge branch 'main' into release/1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tonilastre committed Dec 15, 2023
2 parents 900f989 + 8b3dd06 commit c26dd8a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.4.2

### Fix

* Fix: resizeObserver is not unobserved (#82) (fixes #81) - by @markusnissl

## 0.4.1

### Fix
Expand Down
6 changes: 4 additions & 2 deletions src/views/orb-map-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export type IOrbMapViewSettingsUpdate<N extends INodeBase, E extends IEdgeBase>

export class OrbMapView<N extends INodeBase, E extends IEdgeBase> implements IOrbView<N, E, IOrbMapViewSettings<N, E>> {
private _container: HTMLElement;
private _resizeObs: ResizeObserver;
private _graph: IGraph<N, E>;
private _events: OrbEmitter<N, E>;
private _strategy: IEventStrategy<N, E>;
Expand Down Expand Up @@ -131,8 +132,8 @@ export class OrbMapView<N extends INodeBase, E extends IEdgeBase> implements IOr
this._settings.render = this._renderer.getSettings();

// Resize the canvas based on the dimensions of it's parent container <div>.
const resizeObs = new ResizeObserver(() => this._handleResize());
resizeObs.observe(this._container);
this._resizeObs = new ResizeObserver(() => this._handleResize());
this._resizeObs.observe(this._container);
this._handleResize();

this._leaflet = this._initLeaflet();
Expand Down Expand Up @@ -207,6 +208,7 @@ export class OrbMapView<N extends INodeBase, E extends IEdgeBase> implements IOr
}

destroy() {
this._resizeObs.unobserve(this._container);
this._renderer.removeAllListeners();
this._leaflet.off();
this._leaflet.remove();
Expand Down
6 changes: 4 additions & 2 deletions src/views/orb-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export type IOrbViewSettingsInit<N extends INodeBase, E extends IEdgeBase> = Omi

export class OrbView<N extends INodeBase, E extends IEdgeBase> implements IOrbView<N, E, IOrbViewSettings<N, E>> {
private _container: HTMLElement;
private _resizeObs: ResizeObserver;
private _graph: IGraph<N, E>;
private _events: OrbEmitter<N, E>;
private _strategy: IEventStrategy<N, E>;
Expand Down Expand Up @@ -127,8 +128,8 @@ export class OrbView<N extends INodeBase, E extends IEdgeBase> implements IOrbVi
this._settings.render = this._renderer.getSettings();

// Resize the canvas based on the dimensions of its parent container <div>.
const resizeObs = new ResizeObserver(() => this._handleResize());
resizeObs.observe(this._container);
this._resizeObs = new ResizeObserver(() => this._handleResize());
this._resizeObs.observe(this._container);
this._handleResize();

this._d3Zoom = zoom<HTMLCanvasElement, any>()
Expand Down Expand Up @@ -277,6 +278,7 @@ export class OrbView<N extends INodeBase, E extends IEdgeBase> implements IOrbVi
}

destroy() {
this._resizeObs.unobserve(this._container);
this._renderer.removeAllListeners();
this._simulator.terminate();
this._canvas.outerHTML = '';
Expand Down

0 comments on commit c26dd8a

Please sign in to comment.