Skip to content

Commit

Permalink
[Time Conductor] Destroy listeners in ConductorAxisController
Browse files Browse the repository at this point in the history
  • Loading branch information
akhenry committed Sep 22, 2016
1 parent 98122cc commit 49ee5cb
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,22 @@ define(
this.initialized = false;
this.msPerPixel = undefined;

this.setScale = this.setScale.bind(this);
this.changeBounds = this.changeBounds.bind(this);
this.changeTimeSystem = this.changeTimeSystem.bind(this);

this.bounds = conductor.bounds();
this.timeSystem = conductor.timeSystem();

//Bind all class functions to 'this'
Object.keys(ConductorAxisController.prototype).filter(function (key) {
return typeof ConductorAxisController.prototype[key] === 'function';
}).forEach(function (key) {
self[key] = self[key].bind(self);
});
}

ConductorAxisController.prototype.destroy = function () {
this.conductor.off('timeSystem', this.changeTimeSystem);
this.conductor.off('bounds', this.setScale);
};

ConductorAxisController.prototype.changeBounds = function (bounds) {
this.bounds = bounds;
if (this.initialized) {
Expand Down Expand Up @@ -136,6 +144,8 @@ define(
this.conductor.on("timeSystem", this.changeTimeSystem);
this.conductor.on("bounds", this.changeBounds);

this.scope.$on("$destroy", this.destroy);

scope.$on("zoom", function (evt, bounds){
this.changeBounds(bounds);
}.bind(this));
Expand Down

0 comments on commit 49ee5cb

Please sign in to comment.