diff --git a/HISTORY.md b/HISTORY.md index 9017e43c..c859d549 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -6,6 +6,7 @@ http://visjs.org ### Timeline +- Implemented function `destroy` to neatly cleanup a Timeline. - Implemented support for dragging the timeline contents vertically. - Implemented options `zoomable` and `moveable`. - Changed default value of option `showCurrentTime` to true. diff --git a/docs/timeline.html b/docs/timeline.html index 1284fc5a..6907887d 100644 --- a/docs/timeline.html +++ b/docs/timeline.html @@ -673,6 +673,13 @@ timeline.clear({options: true}); // clear options only + + destroy() + none + Destroy the Timeline. The timeline is removed from memory. all DOM elements and event listeners are cleaned up. + + + fit() none diff --git a/src/timeline/Timeline.js b/src/timeline/Timeline.js index 067d71db..38299f77 100644 --- a/src/timeline/Timeline.js +++ b/src/timeline/Timeline.js @@ -227,7 +227,7 @@ Timeline.prototype.destroy = function () { // cleanup hammer touch events for (var event in this.listeners) { if (this.listeners.hasOwnProperty(event)) { - this.hammer.off(event, this.listeners[event]); + delete this.listeners[event]; } } this.listeners = null; @@ -238,17 +238,6 @@ Timeline.prototype.destroy = function () { component.destroy(); }); - // remove all components - this.components = []; - this.range = null; - this.timeAxis = null; - this.itemSet = null; - this.currentTime = null; - this.customTime = null; - - //this.body.util.snap = null; - //this.body.util.toTime = null; - //this.body.util.toScreen = null; this.body = null; }; diff --git a/src/timeline/component/ItemSet.js b/src/timeline/component/ItemSet.js index 05ebdd2f..56dba106 100644 --- a/src/timeline/component/ItemSet.js +++ b/src/timeline/component/ItemSet.js @@ -296,7 +296,6 @@ ItemSet.prototype.destroy = function() { this.setItems(null); this.setGroups(null); - this.hammer.enable(false); this.hammer = null; this.body = null;