@ -148,8 +148,6 @@ Group.prototype.getLabelWidth = function() {
Group . prototype . redraw = function ( range , margin , restack ) {
var resized = false ;
this . visibleItems = this . _updateVisibleItems ( this . orderedItems , this . visibleItems , range ) ;
// force recalculation of the height of the items when the marker height changed
// (due to the Timeline being attached to the DOM or changed from display:none to visible)
var markerHeight = this . dom . marker . clientHeight ;
@ -165,18 +163,41 @@ Group.prototype.redraw = function(range, margin, restack) {
}
// reposition visible items vertically
var customOrderedItems = null ;
if ( this . itemSet . options . stack ) { // TODO: ugly way to access options...
if ( typeof this . itemSet . options . order === 'function' || false ) {
customOrderedItems = this . _getCustomOrderedItems ( ) ;
stack . stack ( customOrderedItems , margin , true ) ;
if ( typeof this . itemSet . options . order === 'function' ) {
// a custom order function
if ( restack ) {
// brute force restack of all items
// show all items
var me = this ;
util . forEach ( this . items , function ( item ) {
if ( ! item . displayed ) {
item . redraw ( ) ;
me . visibleItems . push ( item ) ;
}
item . repositionX ( ) ;
} ) ;
// order all items and force a restacking
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 */ ) ;
}
else {
this . visibleItems = this . _updateVisibleItems ( this . orderedItems , this . visibleItems , range ) ;
}
else {
// no custom order function, lazy stacking
this . visibleItems = this . _updateVisibleItems ( this . orderedItems , this . visibleItems , range ) ;
if ( this . itemSet . options . stack ) { // TODO: ugly way to access options...
stack . stack ( this . visibleItems , margin , restack ) ;
}
}
else { // no stacking
stack . nostack ( this . visibleItems , margin , this . subgroups ) ;
else { // no stacking
stack . nostack ( this . visibleItems , margin , this . subgroups ) ;
}
}
// recalculate the height of the group
@ -490,23 +511,6 @@ Group.prototype._updateVisibleItems = function(orderedItems, oldVisibleItems, ra
return visibleItems ;
} ;
Group . prototype . _getCustomOrderedItems = function ( ) {
var customOrderedItems = this . orderedItems . byStart . filter ( function ( item ) {
return item . height !== 0 || item . width !== 0 ;
} ) ;
var me = this ;
customOrderedItems . sort ( function ( a , b ) {
return me . itemSet . options . order ( a . data , b . data ) ;
} ) ;
customOrderedItems . forEach ( function ( item ) {
item . repositionX ( ) ;
} ) ;
return customOrderedItems ;
} ;
Group . prototype . _traceVisible = function ( initialPos , items , visibleItems , visibleItemsLookup , breakCondition ) {
var item ;
var i ;