From 77cf6df50b0e6072200ce4cca49b5a536a88bc7c Mon Sep 17 00:00:00 2001 From: yotamberk Date: Thu, 29 Jun 2017 10:27:54 +0300 Subject: [PATCH] Fix subgroup collision (#3200) * Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * created a checklist for the release process * unchecked everything * added make github release * Fix colliding subgroups when having same end-start times * Remove npm-debug logs --- .../items/expectedVsActualTimesItems.html | 21 ++++++++++++++++++- lib/timeline/component/Group.js | 8 +++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/examples/timeline/items/expectedVsActualTimesItems.html b/examples/timeline/items/expectedVsActualTimesItems.html index eda66556..7a5facca 100644 --- a/examples/timeline/items/expectedVsActualTimesItems.html +++ b/examples/timeline/items/expectedVsActualTimesItems.html @@ -85,13 +85,32 @@ group:'group1', subgroup:'sg_2' }, - { + { id: 4, content: 'item 2 (actual time)', start: '2014-01-14T12:00:00', end: '2014-01-17T12:00:00', group:'group1', subgroup:'sg_2' + }, + + // subgroup 3 + { + id: 5, + content: 'item 3 (expected time)', + className: 'expected', + start: '2014-01-17T12:00:00', + end: '2014-01-19T12:00:00', + group:'group1', + subgroup:'sg_3' + }, + { + id: 6, + content: 'item 3 (actual time)', + start: '2014-01-17T12:00:00', + end: '2014-01-18T12:00:00', + group:'group1', + subgroup:'sg_3' } ]); diff --git a/lib/timeline/component/Group.js b/lib/timeline/component/Group.js index 2a6d550b..79ccf60d 100644 --- a/lib/timeline/component/Group.js +++ b/lib/timeline/component/Group.js @@ -246,6 +246,7 @@ Group.prototype.redraw = function(range, margin, forceRestack) { var restack = forceRestack || this.stackDirty || (this.isVisible && !lastIsVisible); + this._updateSubgroupsSizes(); // if restacking, reposition visible items vertically if(restack) { if (typeof this.itemSet.options.order === 'function') { @@ -285,9 +286,6 @@ Group.prototype.redraw = function(range, margin, forceRestack) { this.stackDirty = false; } - - this._updateSubgroupsSizes(); - // recalculate the height of the group var height = this._calculateHeight(margin); @@ -486,7 +484,7 @@ Group.prototype._updateSubgroupsSizes = function () { if (me.subgroups) { for (var subgroup in me.subgroups) { var newStart = me.subgroups[subgroup].items[0].data.start; - var newEnd = me.subgroups[subgroup].items[0].data.end; + var newEnd = me.subgroups[subgroup].items[0].data.end - 1; me.subgroups[subgroup].items.forEach(function(item) { if (new Date(item.data.start) < new Date(newStart)) { @@ -498,7 +496,7 @@ Group.prototype._updateSubgroupsSizes = function () { }) me.subgroups[subgroup].start = newStart; - me.subgroups[subgroup].end = newEnd; + me.subgroups[subgroup].end = new Date(newEnd - 1) // -1 to compensate for colliding end to start subgroups; } }