Skip to content

Commit

Permalink
Merge pull request #232 from vidartf/fix-controls
Browse files Browse the repository at this point in the history
Fix controls management
  • Loading branch information
vidartf committed Nov 5, 2018
2 parents e7cd513 + 3b31442 commit 03a509d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions js/src/_base/Renderable.js
Expand Up @@ -395,11 +395,12 @@ var RenderableView = widgets.DOMWidgetView.extend({

enableControls: function() {
this.debug('Enable controls');
this.boundTick = this.tick.bind(this);
var that = this;
this.controls.forEach(function(control) {
control.enabled = true;
control.connectEvents(that.$renderer[0]);
control.addEventListener('change', that.tick.bind(that));
control.addEventListener('change', that.boundTick);
});
},

Expand All @@ -409,7 +410,7 @@ var RenderableView = widgets.DOMWidgetView.extend({
this.controls.forEach(function(control) {
control.enabled = false;
control.dispose(); // Disconnect from DOM events
control.removeEventListener('change', that.tick.bind(that));
control.removeEventListener('change', that.boundTick);
});
},

Expand Down
1 change: 1 addition & 0 deletions js/src/core/Renderer.js
Expand Up @@ -130,6 +130,7 @@ var RendererView = RenderableView.extend({
this.model.get('controls').forEach(function (controlModel) {
controls.push(controlModel.obj);
});
this.controls = controls;

if (!this.isFrozen) {
this.enableControls();
Expand Down

0 comments on commit 03a509d

Please sign in to comment.