@ -81,7 +81,7 @@ Range.prototype.setOptions = function (options) {
// copy the options that we know
// copy the options that we know
var fields = [
var fields = [
'direction' , 'min' , 'max' , 'zoomMin' , 'zoomMax' , 'moveable' , 'zoomable' ,
'direction' , 'min' , 'max' , 'zoomMin' , 'zoomMax' , 'moveable' , 'zoomable' ,
'moment' , 'activate' , 'hiddenDates' , 'zoomKey' , 'rtl'
'moment' , 'activate' , 'hiddenDates' , 'zoomKey' , 'rtl' , 'horizontalScroll'
] ;
] ;
util . selectiveExtend ( fields , this . options , options ) ;
util . selectiveExtend ( fields , this . options , options ) ;
@ -483,15 +483,10 @@ Range.prototype._onDragEnd = function (event) {
* @ private
* @ private
* /
* /
Range . prototype . _onMouseWheel = function ( event ) {
Range . prototype . _onMouseWheel = function ( event ) {
// only allow zooming when configured as zoomable and moveable
if ( ! ( this . options . zoomable && this . options . moveable ) ) return ;
// only zoom when the mouse is inside the current range
if ( ! this . _isInsideRange ( event ) ) return ;
// Prevent default actions caused by mouse wheel
// (else the page and timeline both zoom and scroll)
event . preventDefault ( ) ;
// only zoom when the according key is pressed and the zoomKey option is set
if ( this . options . zoomKey && ! event [ this . options . zoomKey ] ) return ;
// retrieve delta
// retrieve delta
var delta = 0 ;
var delta = 0 ;
if ( event . wheelDelta ) { /* IE/Opera. */
if ( event . wheelDelta ) { /* IE/Opera. */
@ -502,6 +497,27 @@ Range.prototype._onMouseWheel = function(event) {
delta = - event . detail / 3 ;
delta = - event . detail / 3 ;
}
}
// don't allow zoom when the according key is pressed and the zoomKey option or not zoomable but movable
if ( ( this . options . zoomKey && ! event [ this . options . zoomKey ] && this . options . zoomable )
|| ( ! this . options . zoomable && this . options . moveable ) ) {
if ( this . options . horizontalScroll ) {
// calculate a single scroll jump relative to the range scale
var diff = delta * ( this . end - this . start ) / 20 ;
// calculate new start and end
var newStart = this . start - diff ;
var newEnd = this . end - diff ;
this . setRange ( newStart , newEnd ) ;
}
return ;
}
// only allow zooming when configured as zoomable and moveable
if ( ! ( this . options . zoomable && this . options . moveable ) ) return ;
// only zoom when the mouse is inside the current range
if ( ! this . _isInsideRange ( event ) ) return ;
// If delta is nonzero, handle it.
// If delta is nonzero, handle it.
// Basically, delta is now positive if wheel was scrolled up,
// Basically, delta is now positive if wheel was scrolled up,
// and negative, if wheel was scrolled down.
// and negative, if wheel was scrolled down.
@ -524,10 +540,6 @@ Range.prototype._onMouseWheel = function(event) {
this . zoom ( scale , pointerDate , delta ) ;
this . zoom ( scale , pointerDate , delta ) ;
}
}
// Prevent default actions caused by mouse wheel
// (else the page and timeline both zoom and scroll)
event . preventDefault ( ) ;
} ;
} ;
/ * *
/ * *