diff --git a/HISTORY.md b/HISTORY.md index d13c55f3..b5a5e5c8 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -12,6 +12,7 @@ http://visjs.org on the manipulation toolbar. - Fixed #1334 (again): Network now ignores scroll when interaction:zoomView is false. - Added options to customize the hierarchical layout without the use of physics. +- Fixed #1588: destroy now unsubscribed from the dataset. ### Graph2d diff --git a/dist/vis.js b/dist/vis.js index 11bfbc55..f4193f82 100644 --- a/dist/vis.js +++ b/dist/vis.js @@ -5,7 +5,7 @@ * A dynamic, browser-based visualization library. * * @version 4.12.1-SNAPSHOT - * @date 2016-01-18 + * @date 2016-01-19 * * @license * Copyright (C) 2011-2016 Almende B.V, http://almende.com @@ -28577,6 +28577,9 @@ return /******/ (function(modules) { // webpackBootstrap this.body.emitter.on('refreshNodes', this.refresh.bind(this)); this.body.emitter.on('refresh', this.refresh.bind(this)); this.body.emitter.on('destroy', function () { + util.forEach(_this2.nodesListeners, function (callback, event) { + if (_this2.body.data.nodes) _this2.body.data.nodes.off(event, callback); + }); delete _this2.body.functions.createNode; delete _this2.nodesListeners.add; delete _this2.nodesListeners.update; @@ -31517,6 +31520,9 @@ return /******/ (function(modules) { // webpackBootstrap this.body.emitter.on("refreshEdges", this.refresh.bind(this)); this.body.emitter.on("refresh", this.refresh.bind(this)); this.body.emitter.on("destroy", function () { + util.forEach(_this2.edgesListeners, function (callback, event) { + if (_this2.body.data.edges) _this2.body.data.edges.off(event, callback); + }); delete _this2.body.functions.createEdge; delete _this2.edgesListeners.add; delete _this2.edgesListeners.update; diff --git a/lib/network/modules/EdgesHandler.js b/lib/network/modules/EdgesHandler.js index f66fbe1e..4be26d95 100644 --- a/lib/network/modules/EdgesHandler.js +++ b/lib/network/modules/EdgesHandler.js @@ -141,6 +141,10 @@ class EdgesHandler { this.body.emitter.on("refreshEdges", this.refresh.bind(this)); this.body.emitter.on("refresh", this.refresh.bind(this)); this.body.emitter.on("destroy", () => { + util.forEach(this.edgesListeners, (callback, event) => { + if (this.body.data.edges) + this.body.data.edges.off(event, callback); + }); delete this.body.functions.createEdge; delete this.edgesListeners.add; delete this.edgesListeners.update; diff --git a/lib/network/modules/NodesHandler.js b/lib/network/modules/NodesHandler.js index cbf0450a..f7f6d650 100644 --- a/lib/network/modules/NodesHandler.js +++ b/lib/network/modules/NodesHandler.js @@ -115,6 +115,10 @@ class NodesHandler { this.body.emitter.on('refreshNodes', this.refresh.bind(this)); this.body.emitter.on('refresh', this.refresh.bind(this)); this.body.emitter.on('destroy', () => { + util.forEach(this.nodesListeners, (callback, event) => { + if (this.body.data.nodes) + this.body.data.nodes.off(event, callback); + }); delete this.body.functions.createNode; delete this.nodesListeners.add; delete this.nodesListeners.update; diff --git a/package.json b/package.json index f9508671..76fc4325 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "network", "browser" ], - "main": "./dist/vis.min.js", + "main": "./dist/vis.js", "scripts": { "test": "mocha", "build": "gulp",