|
|
@ -1,5 +1,4 @@ |
|
|
|
var util = require('../util'); |
|
|
|
var hammerUtil = require('../hammerUtil'); |
|
|
|
var moment = require('../module/moment'); |
|
|
|
var Component = require('./component/Component'); |
|
|
|
var DateUtil = require('./DateUtil'); |
|
|
@ -22,7 +21,7 @@ function Range(body, options) { |
|
|
|
this.start = start; |
|
|
|
this.end = end; |
|
|
|
} else { |
|
|
|
this.start = options.start || start |
|
|
|
this.start = options.start || start; |
|
|
|
this.end = options.end || end |
|
|
|
} |
|
|
|
|
|
|
@ -141,7 +140,6 @@ Range.prototype.startRolling = function() { |
|
|
|
|
|
|
|
var start = t - interval * (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 = { |
|
|
|
animation: false |
|
|
@ -150,7 +148,7 @@ Range.prototype.startRolling = function() { |
|
|
|
|
|
|
|
// determine interval to refresh
|
|
|
|
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 > 1000) interval = 1000; |
|
|
|
|
|
|
@ -235,7 +233,7 @@ Range.prototype.setRange = function(start, end, options, callback) { |
|
|
|
end: new Date(me.end), |
|
|
|
byUser: options.byUser, |
|
|
|
event: options.event |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
if (changed) { |
|
|
|
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; |
|
|
|
} |
|
|
|
return this.millisecondsPerPixelCache; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* Stop an animation |
|
|
@ -501,7 +499,7 @@ Range.prototype._onDragStart = function(event) { |
|
|
|
* @private |
|
|
|
*/ |
|
|
|
Range.prototype._onDrag = function (event) { |
|
|
|
if (!event) return |
|
|
|
if (!event) return; |
|
|
|
|
|
|
|
if (!this.props.touch.dragging) return; |
|
|
|
|
|
|
@ -524,11 +522,11 @@ Range.prototype._onDrag = function (event) { |
|
|
|
interval -= duration; |
|
|
|
|
|
|
|
var width = (direction == 'horizontal') ? this.body.domProps.center.width : this.body.domProps.center.height; |
|
|
|
|
|
|
|
var diffRange; |
|
|
|
if (this.options.rtl) { |
|
|
|
var diffRange = delta / width * interval; |
|
|
|
diffRange = delta / width * interval; |
|
|
|
} else { |
|
|
|
var diffRange = -delta / width * interval; |
|
|
|
diffRange = -delta / width * interval; |
|
|
|
} |
|
|
|
|
|
|
|
var newStart = this.props.touch.start + diffRange; |
|
|
@ -640,7 +638,7 @@ Range.prototype._onMouseWheel = function(event) { |
|
|
|
} |
|
|
|
|
|
|
|
// calculate center, the date to zoom around
|
|
|
|
var pointerDate |
|
|
|
var pointerDate; |
|
|
|
if (this.rolling) { |
|
|
|
pointerDate = this.start + ((this.end - this.start) * this.options.rollingMode.offset); |
|
|
|
} else { |
|
|
@ -659,7 +657,7 @@ Range.prototype._onMouseWheel = function(event) { |
|
|
|
* Start of a touch gesture |
|
|
|
* @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.end = this.end; |
|
|
|
this.props.touch.allowDragging = true; |
|
|
@ -714,7 +712,7 @@ Range.prototype._onPinch = function (event) { |
|
|
|
animation: false, |
|
|
|
byUser: true, |
|
|
|
event: event |
|
|
|
} |
|
|
|
}; |
|
|
|
this.setRange(newStart, newEnd, options); |
|
|
|
|
|
|
|
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
|
|
|
|
// and no scroll action should happen.
|
|
|
|
var clientX = event.center ? event.center.x : event.clientX; |
|
|
|
var x; |
|
|
|
if (this.options.rtl) { |
|
|
|
var x = clientX - util.getAbsoluteLeft(this.body.dom.centerContainer); |
|
|
|
x = clientX - util.getAbsoluteLeft(this.body.dom.centerContainer); |
|
|
|
} 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); |
|
|
|
|
|
|
@ -783,7 +782,7 @@ Range.prototype.getPointer = function (touch, element) { |
|
|
|
y: touch.y - util.getAbsoluteTop(element) |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* 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, |
|
|
|
byUser: true, |
|
|
|
event: event |
|
|
|
} |
|
|
|
}; |
|
|
|
this.setRange(newStart, newEnd, options); |
|
|
|
|
|
|
|
this.startToFront = false; // revert to default
|
|
|
@ -869,7 +868,7 @@ Range.prototype.moveTo = function(moveTo) { |
|
|
|
animation: false, |
|
|
|
byUser: true, |
|
|
|
event: null |
|
|
|
} |
|
|
|
}; |
|
|
|
this.setRange(newStart, newEnd, options); |
|
|
|
}; |
|
|
|
|
|
|
|