diff --git a/src/timeline/component/Group.js b/src/timeline/component/Group.js index ec9e4377..24a57b91 100644 --- a/src/timeline/component/Group.js +++ b/src/timeline/component/Group.js @@ -134,10 +134,6 @@ Group.prototype.redraw = function redraw(range, margin, restack) { else { // no stacking stack.nostack(this.visibleItems, margin); } - for (var i = 0, ii = this.visibleItems.length; i < ii; i++) { - var item = this.visibleItems[i]; - item.repositionY(); - } // recalculate the height of the group var height; @@ -171,6 +167,12 @@ Group.prototype.redraw = function redraw(range, margin, restack) { foreground.style.height = height + 'px'; this.dom.label.style.height = height + 'px'; + // update vertical position of items after they are re-stacked and the height of the group is calculated + for (var i = 0, ii = this.visibleItems.length; i < ii; i++) { + var item = this.visibleItems[i]; + item.repositionY(); + } + return resized; }; diff --git a/src/timeline/component/ItemSet.js b/src/timeline/component/ItemSet.js index ca65bd11..d8bb8028 100644 --- a/src/timeline/component/ItemSet.js +++ b/src/timeline/component/ItemSet.js @@ -313,7 +313,8 @@ ItemSet.prototype.redraw = function redraw() { minHeight = margin.axis + margin.item; util.forEach(this.groups, function (group) { var groupMargin = (group == firstGroup) ? firstMargin : nonFirstMargin; - resized = group.redraw(range, groupMargin, restack) || resized; + var groupResized = group.redraw(range, groupMargin, restack); + resized = groupResized || resized; height += group.height; }); height = Math.max(height, minHeight);