|
@ -1,5 +1,4 @@ |
|
|
var util = require('../util'); |
|
|
var util = require('../util'); |
|
|
var hammerUtil = require('../hammerUtil'); |
|
|
|
|
|
var moment = require('../module/moment'); |
|
|
var moment = require('../module/moment'); |
|
|
var Component = require('./component/Component'); |
|
|
var Component = require('./component/Component'); |
|
|
var DateUtil = require('./DateUtil'); |
|
|
var DateUtil = require('./DateUtil'); |
|
@ -22,7 +21,7 @@ function Range(body, options) { |
|
|
this.start = start; |
|
|
this.start = start; |
|
|
this.end = end; |
|
|
this.end = end; |
|
|
} else { |
|
|
} else { |
|
|
this.start = options.start || start |
|
|
|
|
|
|
|
|
this.start = options.start || start; |
|
|
this.end = options.end || end |
|
|
this.end = options.end || end |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -141,7 +140,6 @@ Range.prototype.startRolling = function() { |
|
|
|
|
|
|
|
|
var start = t - interval * (me.options.rollingMode.offset); |
|
|
var start = t - interval * (me.options.rollingMode.offset); |
|
|
var end = t + interval * (1 - me.options.rollingMode.offset); |
|
|
var end = t + interval * (1 - me.options.rollingMode.offset); |
|
|
var animation = (me.options && me.options.animation !== undefined) ? me.options.animation : true; |
|
|
|
|
|
|
|
|
|
|
|
var options = { |
|
|
var options = { |
|
|
animation: false |
|
|
animation: false |
|
@ -150,7 +148,7 @@ Range.prototype.startRolling = function() { |
|
|
|
|
|
|
|
|
// determine interval to refresh
|
|
|
// determine interval to refresh
|
|
|
var scale = me.conversion(me.body.domProps.center.width).scale; |
|
|
var scale = me.conversion(me.body.domProps.center.width).scale; |
|
|
var interval = 1 / scale / 10; |
|
|
|
|
|
|
|
|
interval = 1 / scale / 10; |
|
|
if (interval < 30) interval = 30; |
|
|
if (interval < 30) interval = 30; |
|
|
if (interval > 1000) interval = 1000; |
|
|
if (interval > 1000) interval = 1000; |
|
|
|
|
|
|
|
@ -235,7 +233,7 @@ Range.prototype.setRange = function(start, end, options, callback) { |
|
|
end: new Date(me.end), |
|
|
end: new Date(me.end), |
|
|
byUser: options.byUser, |
|
|
byUser: options.byUser, |
|
|
event: options.event |
|
|
event: options.event |
|
|
} |
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
if (changed) { |
|
|
if (changed) { |
|
|
me.body.emitter.emit('rangechange', params); |
|
|
me.body.emitter.emit('rangechange', params); |
|
@ -286,7 +284,7 @@ Range.prototype.getMillisecondsPerPixel = function() { |
|
|
this.millisecondsPerPixelCache = (this.end - this.start) / this.body.dom.center.clientWidth; |
|
|
this.millisecondsPerPixelCache = (this.end - this.start) / this.body.dom.center.clientWidth; |
|
|
} |
|
|
} |
|
|
return this.millisecondsPerPixelCache; |
|
|
return this.millisecondsPerPixelCache; |
|
|
} |
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Stop an animation |
|
|
* Stop an animation |
|
@ -501,7 +499,7 @@ Range.prototype._onDragStart = function(event) { |
|
|
* @private |
|
|
* @private |
|
|
*/ |
|
|
*/ |
|
|
Range.prototype._onDrag = function (event) { |
|
|
Range.prototype._onDrag = function (event) { |
|
|
if (!event) return |
|
|
|
|
|
|
|
|
if (!event) return; |
|
|
|
|
|
|
|
|
if (!this.props.touch.dragging) return; |
|
|
if (!this.props.touch.dragging) return; |
|
|
|
|
|
|
|
@ -524,11 +522,11 @@ Range.prototype._onDrag = function (event) { |
|
|
interval -= duration; |
|
|
interval -= duration; |
|
|
|
|
|
|
|
|
var width = (direction == 'horizontal') ? this.body.domProps.center.width : this.body.domProps.center.height; |
|
|
var width = (direction == 'horizontal') ? this.body.domProps.center.width : this.body.domProps.center.height; |
|
|
|
|
|
|
|
|
|
|
|
var diffRange; |
|
|
if (this.options.rtl) { |
|
|
if (this.options.rtl) { |
|
|
var diffRange = delta / width * interval; |
|
|
|
|
|
|
|
|
diffRange = delta / width * interval; |
|
|
} else { |
|
|
} else { |
|
|
var diffRange = -delta / width * interval; |
|
|
|
|
|
|
|
|
diffRange = -delta / width * interval; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var newStart = this.props.touch.start + diffRange; |
|
|
var newStart = this.props.touch.start + diffRange; |
|
@ -640,7 +638,7 @@ Range.prototype._onMouseWheel = function(event) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// calculate center, the date to zoom around
|
|
|
// calculate center, the date to zoom around
|
|
|
var pointerDate |
|
|
|
|
|
|
|
|
var pointerDate; |
|
|
if (this.rolling) { |
|
|
if (this.rolling) { |
|
|
pointerDate = this.start + ((this.end - this.start) * this.options.rollingMode.offset); |
|
|
pointerDate = this.start + ((this.end - this.start) * this.options.rollingMode.offset); |
|
|
} else { |
|
|
} else { |
|
@ -659,7 +657,7 @@ Range.prototype._onMouseWheel = function(event) { |
|
|
* Start of a touch gesture |
|
|
* Start of a touch gesture |
|
|
* @private |
|
|
* @private |
|
|
*/ |
|
|
*/ |
|
|
Range.prototype._onTouch = function (event) { |
|
|
|
|
|
|
|
|
Range.prototype._onTouch = function (event) { // eslint-disable-line no-unused-vars
|
|
|
this.props.touch.start = this.start; |
|
|
this.props.touch.start = this.start; |
|
|
this.props.touch.end = this.end; |
|
|
this.props.touch.end = this.end; |
|
|
this.props.touch.allowDragging = true; |
|
|
this.props.touch.allowDragging = true; |
|
@ -714,7 +712,7 @@ Range.prototype._onPinch = function (event) { |
|
|
animation: false, |
|
|
animation: false, |
|
|
byUser: true, |
|
|
byUser: true, |
|
|
event: event |
|
|
event: event |
|
|
} |
|
|
|
|
|
|
|
|
}; |
|
|
this.setRange(newStart, newEnd, options); |
|
|
this.setRange(newStart, newEnd, options); |
|
|
|
|
|
|
|
|
this.startToFront = false; // revert to default
|
|
|
this.startToFront = false; // revert to default
|
|
@ -732,10 +730,11 @@ Range.prototype._isInsideRange = function(event) { |
|
|
// calculate the time where the mouse is, check whether inside
|
|
|
// calculate the time where the mouse is, check whether inside
|
|
|
// and no scroll action should happen.
|
|
|
// and no scroll action should happen.
|
|
|
var clientX = event.center ? event.center.x : event.clientX; |
|
|
var clientX = event.center ? event.center.x : event.clientX; |
|
|
|
|
|
var x; |
|
|
if (this.options.rtl) { |
|
|
if (this.options.rtl) { |
|
|
var x = clientX - util.getAbsoluteLeft(this.body.dom.centerContainer); |
|
|
|
|
|
|
|
|
x = clientX - util.getAbsoluteLeft(this.body.dom.centerContainer); |
|
|
} else { |
|
|
} else { |
|
|
var x = util.getAbsoluteRight(this.body.dom.centerContainer) - clientX; |
|
|
|
|
|
|
|
|
x = util.getAbsoluteRight(this.body.dom.centerContainer) - clientX; |
|
|
} |
|
|
} |
|
|
var time = this.body.util.toTime(x); |
|
|
var time = this.body.util.toTime(x); |
|
|
|
|
|
|
|
@ -783,7 +782,7 @@ Range.prototype.getPointer = function (touch, element) { |
|
|
y: touch.y - util.getAbsoluteTop(element) |
|
|
y: touch.y - util.getAbsoluteTop(element) |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Zoom the range the given scale in or out. Start and end date will |
|
|
* Zoom the range the given scale in or out. Start and end date will |
|
@ -823,7 +822,7 @@ Range.prototype.zoom = function(scale, center, delta, event) { |
|
|
animation: false, |
|
|
animation: false, |
|
|
byUser: true, |
|
|
byUser: true, |
|
|
event: event |
|
|
event: event |
|
|
} |
|
|
|
|
|
|
|
|
}; |
|
|
this.setRange(newStart, newEnd, options); |
|
|
this.setRange(newStart, newEnd, options); |
|
|
|
|
|
|
|
|
this.startToFront = false; // revert to default
|
|
|
this.startToFront = false; // revert to default
|
|
@ -869,7 +868,7 @@ Range.prototype.moveTo = function(moveTo) { |
|
|
animation: false, |
|
|
animation: false, |
|
|
byUser: true, |
|
|
byUser: true, |
|
|
event: null |
|
|
event: null |
|
|
} |
|
|
|
|
|
|
|
|
}; |
|
|
this.setRange(newStart, newEnd, options); |
|
|
this.setRange(newStart, newEnd, options); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|