Browse Source

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
revert-3409-performance
yotamberk 7 years ago
committed by GitHub
parent
commit
77cf6df50b
2 changed files with 23 additions and 6 deletions
  1. +20
    -1
      examples/timeline/items/expectedVsActualTimesItems.html
  2. +3
    -5
      lib/timeline/component/Group.js

+ 20
- 1
examples/timeline/items/expectedVsActualTimesItems.html View File

@ -85,13 +85,32 @@
group:'group1', group:'group1',
subgroup:'sg_2' subgroup:'sg_2'
}, },
{
{
id: 4, id: 4,
content: 'item 2 (actual time)', content: 'item 2 (actual time)',
start: '2014-01-14T12:00:00', start: '2014-01-14T12:00:00',
end: '2014-01-17T12:00:00', end: '2014-01-17T12:00:00',
group:'group1', group:'group1',
subgroup:'sg_2' 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'
} }
]); ]);

+ 3
- 5
lib/timeline/component/Group.js View File

@ -246,6 +246,7 @@ Group.prototype.redraw = function(range, margin, forceRestack) {
var restack = forceRestack || this.stackDirty || (this.isVisible && !lastIsVisible); var restack = forceRestack || this.stackDirty || (this.isVisible && !lastIsVisible);
this._updateSubgroupsSizes();
// if restacking, reposition visible items vertically // if restacking, reposition visible items vertically
if(restack) { if(restack) {
if (typeof this.itemSet.options.order === 'function') { if (typeof this.itemSet.options.order === 'function') {
@ -285,9 +286,6 @@ Group.prototype.redraw = function(range, margin, forceRestack) {
this.stackDirty = false; this.stackDirty = false;
} }
this._updateSubgroupsSizes();
// recalculate the height of the group // recalculate the height of the group
var height = this._calculateHeight(margin); var height = this._calculateHeight(margin);
@ -486,7 +484,7 @@ Group.prototype._updateSubgroupsSizes = function () {
if (me.subgroups) { if (me.subgroups) {
for (var subgroup in me.subgroups) { for (var subgroup in me.subgroups) {
var newStart = me.subgroups[subgroup].items[0].data.start; 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) { me.subgroups[subgroup].items.forEach(function(item) {
if (new Date(item.data.start) < new Date(newStart)) { 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].start = newStart;
me.subgroups[subgroup].end = newEnd;
me.subgroups[subgroup].end = new Date(newEnd - an class="mi">1) // -1 to compensate for colliding end to start subgroups;
} }
} }

Loading…
Cancel
Save