diff --git a/src/timeline/component/Group.js b/src/timeline/component/Group.js index 95ddf7ff..ed81dca6 100644 --- a/src/timeline/component/Group.js +++ b/src/timeline/component/Group.js @@ -81,9 +81,9 @@ Group.prototype.setData = function setData(data) { /** * Set item set for the group. The group will create a view on the itemSet, * filtered by the groups id. - * @param {DataSet | DataView} itemSet + * @param {DataSet | DataView} itemsData */ -Group.prototype.setItems = function setItems(itemSet) { +Group.prototype.setItems = function setItems(itemsData) { if (this.itemSet) { // remove current item set this.itemSet.setItems(); @@ -91,17 +91,23 @@ Group.prototype.setItems = function setItems(itemSet) { this.itemSet = null; } - if (itemSet) { + if (itemsData) { var groupId = this.groupId; - var itemSetOptions = Object.create(this.options); + var me = this; + var itemSetOptions = util.extend(this.options, { + height: function () { + // FIXME: setting height doesn't yet work + return Math.max(me.props.label.height, me.itemSet.height); + } + }); this.itemSet = new ItemSet(itemSetOptions); this.itemSet.on('change', this.emit.bind(this, 'change')); // propagate change event this.groupFrame.appendChild(this.itemSet.getFrame()); if (this.range) this.itemSet.setRange(this.range); - this.view = new DataView(itemSet, { + this.view = new DataView(itemsData, { filter: function (item) { return item.group == groupId; } @@ -175,17 +181,21 @@ Group.prototype.getSelection = function getSelection() { * @return {boolean} Returns true if the component is resized */ Group.prototype.repaint = function repaint() { - this.show(); - - var resized = this.itemSet.repaint(); + var resized = false; - this.height = this.itemSet ? this.itemSet.height : 0; + this.show(); - this.dom.label.style.height = this.height + 'px'; + if (this.itemSet) { + resized = this.itemSet.repaint() || resized; + } // calculate inner size of the label resized = util.updateProperty(this.props.label, 'width', this.dom.inner.clientWidth) || resized; resized = util.updateProperty(this.props.label, 'height', this.dom.inner.clientHeight) || resized; + this.height = this.itemSet ? this.itemSet.height : 0; + + this.dom.label.style.height = this.height + 'px'; + return resized; }; diff --git a/src/timeline/component/ItemSet.js b/src/timeline/component/ItemSet.js index ff0c38ac..ddf117ca 100644 --- a/src/timeline/component/ItemSet.js +++ b/src/timeline/component/ItemSet.js @@ -329,6 +329,7 @@ ItemSet.prototype.repaint = function repaint() { frame.style.bottom = asSize((orientation == 'top') ? '' : '0'); frame.style.width = asSize(options.width, '100%'); frame.style.height = asSize(height); + //frame.style.height = asSize('height' in options ? options.height : height); // TODO: reckon with height // calculate actual size and position this.top = frame.offsetTop;