|
|
@ -13,6 +13,7 @@ function Group (groupId, data, itemSet) { |
|
|
|
this.subgroupStack = {}; |
|
|
|
this.subgroupStackAll = false; |
|
|
|
this.doInnerStack = false; |
|
|
|
this.shouldBailStackItems = false; |
|
|
|
this.subgroupIndex = 0; |
|
|
|
this.subgroupOrderer = data && data.subgroupOrder; |
|
|
|
this.itemSet = itemSet; |
|
|
@ -262,6 +263,35 @@ Group.prototype._calculateGroupSizeAndPosition = function() { |
|
|
|
this.width = offsetWidth; |
|
|
|
} |
|
|
|
|
|
|
|
Group.prototype._shouldBailItemsRedraw = function() { |
|
|
|
var me = this; |
|
|
|
var timeoutOptions = this.itemSet.options.onTimeout; |
|
|
|
var bailOptions = { |
|
|
|
relativeBailingTime: this.itemSet.itemsSettingTime, |
|
|
|
bailTimeMs: timeoutOptions && timeoutOptions.timeoutMs, |
|
|
|
userBailFunction: timeoutOptions && timeoutOptions.callback, |
|
|
|
shouldBailStackItems: this.shouldBailStackItems |
|
|
|
}; |
|
|
|
var bail = null; |
|
|
|
if (!this.itemSet.initialDrawDone) { |
|
|
|
if (bailOptions.shouldBailStackItems) { return true; } |
|
|
|
if (Math.abs(new Date() - new Date(bailOptions.relativeBailingTime)) > bailOptions.bailTimeMs) { |
|
|
|
if (bailOptions.userBailFunction && this.itemSet.userContinueNotBail == null) { |
|
|
|
bailOptions.userBailFunction(function(didUserContinue) { |
|
|
|
me.itemSet.userContinueNotBail = didUserContinue; |
|
|
|
bail = !didUserContinue; |
|
|
|
}) |
|
|
|
} else if (me.itemSet.userContinueNotBail == false) { |
|
|
|
bail = true; |
|
|
|
} else { |
|
|
|
bail = false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return bail; |
|
|
|
} |
|
|
|
|
|
|
|
Group.prototype._redrawItems = function(forceRestack, lastIsVisible, margin, range) { |
|
|
|
var restack = forceRestack || this.stackDirty || this.isVisible && !lastIsVisible; |
|
|
|
|
|
|
@ -270,6 +300,7 @@ Group.prototype._redrawItems = function(forceRestack, lastIsVisible, margin, ran |
|
|
|
var visibleSubgroups = {}; |
|
|
|
var subgroup = null; |
|
|
|
|
|
|
|
|
|
|
|
if (typeof this.itemSet.options.order === 'function') { |
|
|
|
// a custom order function
|
|
|
|
// brute force restack of all items
|
|
|
@ -321,7 +352,7 @@ Group.prototype._redrawItems = function(forceRestack, lastIsVisible, margin, ran |
|
|
|
var customOrderedItems = this.orderedItems.byStart.slice().sort(function (a, b) { |
|
|
|
return me.itemSet.options.order(a.data, b.data); |
|
|
|
}); |
|
|
|
stack.stack(customOrderedItems, margin, true /* restack=true */); |
|
|
|
this.shouldBailStackItems = stack.stack(customOrderedItems, margin, true, this._shouldBailItemsRedraw.bind(this)); |
|
|
|
} |
|
|
|
|
|
|
|
this.visibleItems = this._updateItemsInRange(this.orderedItems, this.visibleItems, range); |
|
|
@ -339,7 +370,7 @@ Group.prototype._redrawItems = function(forceRestack, lastIsVisible, margin, ran |
|
|
|
} |
|
|
|
else { |
|
|
|
// TODO: ugly way to access options...
|
|
|
|
stack.stack(this.visibleItems, margin, true /* restack=true */); |
|
|
|
this.shouldBailStackItems = stack.stack(this.visibleItems, margin, true, this._shouldBailItemsRedraw.bind(this)); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// no stacking
|
|
|
@ -347,6 +378,9 @@ Group.prototype._redrawItems = function(forceRestack, lastIsVisible, margin, ran |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (this.shouldBailStackItems) { |
|
|
|
this.itemSet.body.emitter.emit('destroyTimeline') |
|
|
|
} |
|
|
|
this.stackDirty = false; |
|
|
|
} |
|
|
|
} |
|
|
|