@ -165,12 +165,11 @@ ItemRange.prototype.hide = function() {
* @ Override
* @ Override
* /
* /
ItemRange . prototype . repositionX = function ( ) {
ItemRange . prototype . repositionX = function ( ) {
var props = this . props ,
parentWidth = this . parent . width ,
start = this . conversion . toScreen ( this . data . start ) ,
end = this . conversion . toScreen ( this . data . end ) ,
padding = this . options . padding ,
contentLeft ;
var parentWidth = this . parent . width ;
var start = this . conversion . toScreen ( this . data . start ) ;
var end = this . conversion . toScreen ( this . data . end ) ;
var contentLeft ;
var contentWidth ;
// limit the width of the this, as browsers cannot draw very wide divs
// limit the width of the this, as browsers cannot draw very wide divs
if ( start < - parentWidth ) {
if ( start < - parentWidth ) {
@ -182,33 +181,54 @@ ItemRange.prototype.repositionX = function() {
var boxWidth = Math . max ( end - start , 1 ) ;
var boxWidth = Math . max ( end - start , 1 ) ;
if ( this . overflow ) {
if ( this . overflow ) {
// when range exceeds left of the window, position the contents at the left of the visible area
contentLeft = Math . max ( - start , 0 ) ;
this . left = start ;
this . left = start ;
this . width = boxWidth + this . props . content . width ;
this . width = boxWidth + this . props . content . width ;
contentWidth = this . props . content . width ;
// Note: The calculation of width is an optimistic calculation, giving
// Note: The calculation of width is an optimistic calculation, giving
// a width which will not change when moving the Timeline
// a width which will not change when moving the Timeline
// So no restacking needed, which is nicer for the eye;
// So no re- stacking needed, which is nicer for the eye;
}
}
else { // no overflow
// when range exceeds left of the window, position the contents at the left of the visible area
if ( start < 0 ) {
contentLeft = Math . min ( - start ,
( end - start - props . content . width - 2 * padding ) ) ;
// TODO: remove the need for options.padding. it's terrible.
}
else {
contentLeft = 0 ;
}
else {
this . left = start ;
this . left = start ;
this . width = boxWidth ;
this . width = boxWidth ;
contentWidth = Math . min ( end - start , this . props . content . width ) ;
}
}
this . dom . box . style . left = this . left + 'px' ;
this . dom . box . style . left = this . left + 'px' ;
this . dom . box . style . width = boxWidth + 'px' ;
this . dom . box . style . width = boxWidth + 'px' ;
this . dom . content . style . left = contentLeft + 'px' ;
switch ( this . options . align ) {
case 'left' :
this . dom . content . style . left = '0' ;
break ;
case 'right' :
this . dom . content . style . left = Math . max ( ( boxWidth - contentWidth - 2 * this . options . padding ) , 0 ) + 'px' ;
break ;
case 'center' :
this . dom . content . style . left = Math . max ( ( boxWidth - contentWidth - 2 * this . options . padding ) / 2 , 0 ) + 'px' ;
break ;
default : // 'auto'
if ( this . overflow ) {
// when range exceeds left of the window, position the contents at the left of the visible area
contentLeft = Math . max ( - start , 0 ) ;
}
else {
// when range exceeds left of the window, position the contents at the left of the visible area
if ( start < 0 ) {
contentLeft = Math . min ( - start ,
( end - start - this . props . content . width - 2 * this . options . padding ) ) ;
// TODO: remove the need for options.padding. it's terrible.
}
else {
contentLeft = 0 ;
}
}
this . dom . content . style . left = contentLeft + 'px' ;
}
} ;
} ;
/ * *
/ * *