Skip to content

Commit

Permalink
BUGFIX: sizing combineWidgets in manipulateWidgets (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancoisGuillem committed Jan 12, 2017
1 parent 3a15478 commit d389b59
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions inst/htmlwidgets/combineWidgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ HTMLWidgets.widget({

factory: function(el, width, height) {

var widgets = [];
var widgets = {};

function toArray(x) {
if (x.constructor !== Array) x = [x];
Expand All @@ -20,9 +20,15 @@ HTMLWidgets.widget({
}

function resizeAll() {
widgets.forEach(function(x) {
x.factory.resize(x.el, x.el.clientWidth, x.el.clientHeight, x.instance);
});
for (var k in widgets) {
var widgetEl = document.getElementById(k);
if (!widgetEl) {
delete widgets[k];
} else {
var x = widgets[k];
x.factory.resize(widgetEl, widgetEl.clientWidth, widgetEl.clientHeight, x.instance);
}
}
}

return {
Expand All @@ -43,7 +49,7 @@ HTMLWidgets.widget({
var widgetFactory = getWidgetFactory(x.widgetType[i]);
var w = widgetFactory.initialize(child, child.clientWidth, child.clientHeight);
widgetFactory.renderValue(child, x.data[i], w);
widgets.push({factory:widgetFactory, instance:w, el: child});
widgets[x.elementId[i]] = {factory:widgetFactory, instance:w};
}
}

Expand Down

0 comments on commit d389b59

Please sign in to comment.