From da1ff184935a03f8cb70c736726ab60feb404cf5 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Thu, 7 May 2015 18:53:06 -0700 Subject: [PATCH] fix label reposition. fixes #134. --- lib/widgets/element.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/widgets/element.js b/lib/widgets/element.js index e0c23f1..ca9d267 100644 --- a/lib/widgets/element.js +++ b/lib/widgets/element.js @@ -980,11 +980,11 @@ Element.prototype.setLabel = function(options) { self.screen.render(); }; - this.on('scroll', function() { + this.on('scroll', this._labelScroll = function() { reposition(); }); - this.on('resize', function() { + this.on('resize', this._labelResize = function() { nextTick(function() { reposition(); }); @@ -994,6 +994,10 @@ Element.prototype.setLabel = function(options) { Element.prototype.removeLabel = function() { if (!this._label) return; this._label.detach(); + this.removeListener('scroll', this._labelScroll); + this.removeListener('resize', this._labelResize); + delete this._labelScroll; + delete this._labelResize; delete this._label; };