|
@ -116,7 +116,7 @@ function validateDirection (direction) { |
|
|
* @param {Boolean} [byUser=false] |
|
|
* @param {Boolean} [byUser=false] |
|
|
* |
|
|
* |
|
|
*/ |
|
|
*/ |
|
|
Range.prototype.setRange = function(start, end, animation, byUser) { |
|
|
|
|
|
|
|
|
Range.prototype.setRange = function(start, end, animation, byUser, event) { |
|
|
if (byUser !== true) { |
|
|
if (byUser !== true) { |
|
|
byUser = false; |
|
|
byUser = false; |
|
|
} |
|
|
} |
|
@ -151,13 +151,21 @@ Range.prototype.setRange = function(start, end, animation, byUser) { |
|
|
changed = me._applyRange(s, e); |
|
|
changed = me._applyRange(s, e); |
|
|
DateUtil.updateHiddenDates(me.options.moment, me.body, me.options.hiddenDates); |
|
|
DateUtil.updateHiddenDates(me.options.moment, me.body, me.options.hiddenDates); |
|
|
anyChanged = anyChanged || changed; |
|
|
anyChanged = anyChanged || changed; |
|
|
|
|
|
|
|
|
|
|
|
var params = { |
|
|
|
|
|
start: new Date(me.start), |
|
|
|
|
|
end: new Date(me.end), |
|
|
|
|
|
byUser:byUser, |
|
|
|
|
|
event: util.elementsCensor(event) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (changed) { |
|
|
if (changed) { |
|
|
me.body.emitter.emit('rangechange', {start: new Date(me.start), end: new Date(me.end), byUser:byUser}); |
|
|
|
|
|
|
|
|
me.body.emitter.emit('rangechange', params); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (done) { |
|
|
if (done) { |
|
|
if (anyChanged) { |
|
|
if (anyChanged) { |
|
|
me.body.emitter.emit('rangechanged', {start: new Date(me.start), end: new Date(me.end), byUser:byUser}); |
|
|
|
|
|
|
|
|
me.body.emitter.emit('rangechanged', params); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
@ -174,7 +182,12 @@ Range.prototype.setRange = function(start, end, animation, byUser) { |
|
|
var changed = this._applyRange(finalStart, finalEnd); |
|
|
var changed = this._applyRange(finalStart, finalEnd); |
|
|
DateUtil.updateHiddenDates(this.options.moment, this.body, this.options.hiddenDates); |
|
|
DateUtil.updateHiddenDates(this.options.moment, this.body, this.options.hiddenDates); |
|
|
if (changed) { |
|
|
if (changed) { |
|
|
var params = {start: new Date(this.start), end: new Date(this.end), byUser:byUser}; |
|
|
|
|
|
|
|
|
var params = { |
|
|
|
|
|
start: new Date(this.start), |
|
|
|
|
|
end: new Date(this.end), |
|
|
|
|
|
byUser:byUser, |
|
|
|
|
|
event: util.elementsCensor(event) |
|
|
|
|
|
}; |
|
|
this.body.emitter.emit('rangechange', params); |
|
|
this.body.emitter.emit('rangechange', params); |
|
|
this.body.emitter.emit('rangechanged', params); |
|
|
this.body.emitter.emit('rangechanged', params); |
|
|
} |
|
|
} |
|
@ -445,7 +458,8 @@ Range.prototype._onDrag = function (event) { |
|
|
this.body.emitter.emit('rangechange', { |
|
|
this.body.emitter.emit('rangechange', { |
|
|
start: startDate, |
|
|
start: startDate, |
|
|
end: endDate, |
|
|
end: endDate, |
|
|
byUser: true |
|
|
|
|
|
|
|
|
byUser: true, |
|
|
|
|
|
event: util.elementsCensor(event) |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// fire a panmove event
|
|
|
// fire a panmove event
|
|
@ -477,7 +491,8 @@ Range.prototype._onDragEnd = function (event) { |
|
|
this.body.emitter.emit('rangechanged', { |
|
|
this.body.emitter.emit('rangechanged', { |
|
|
start: new Date(this.start), |
|
|
start: new Date(this.start), |
|
|
end: new Date(this.end), |
|
|
end: new Date(this.end), |
|
|
byUser: true |
|
|
|
|
|
|
|
|
byUser: true, |
|
|
|
|
|
event: util.elementsCensor(event) |
|
|
}); |
|
|
}); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
@ -512,7 +527,7 @@ Range.prototype._onMouseWheel = function(event) { |
|
|
var newStart = this.start - diff; |
|
|
var newStart = this.start - diff; |
|
|
var newEnd = this.end - diff; |
|
|
var newEnd = this.end - diff; |
|
|
|
|
|
|
|
|
this.setRange(newStart, newEnd); |
|
|
|
|
|
|
|
|
this.setRange(newStart, newEnd, false, true, event); |
|
|
} |
|
|
} |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
@ -543,7 +558,7 @@ Range.prototype._onMouseWheel = function(event) { |
|
|
var pointer = this.getPointer({x: event.clientX, y: event.clientY}, this.body.dom.center); |
|
|
var pointer = this.getPointer({x: event.clientX, y: event.clientY}, this.body.dom.center); |
|
|
var pointerDate = this._pointerToDate(pointer); |
|
|
var pointerDate = this._pointerToDate(pointer); |
|
|
|
|
|
|
|
|
this.zoom(scale, pointerDate, delta); |
|
|
|
|
|
|
|
|
this.zoom(scale, pointerDate, delta, event); |
|
|
|
|
|
|
|
|
// Prevent default actions caused by mouse wheel
|
|
|
// Prevent default actions caused by mouse wheel
|
|
|
// (else the page and timeline both scroll)
|
|
|
// (else the page and timeline both scroll)
|
|
@ -604,7 +619,7 @@ Range.prototype._onPinch = function (event) { |
|
|
newEnd = safeEnd; |
|
|
newEnd = safeEnd; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.setRange(newStart, newEnd, false, true); |
|
|
|
|
|
|
|
|
this.setRange(newStart, newEnd, false, true, event); |
|
|
|
|
|
|
|
|
this.startToFront = false; // revert to default
|
|
|
this.startToFront = false; // revert to default
|
|
|
this.endToFront = true; // revert to default
|
|
|
this.endToFront = true; // revert to default
|
|
@ -684,7 +699,7 @@ Range.prototype.getPointer = function (touch, element) { |
|
|
* @param {Number} [center] Value representing a date around which will |
|
|
* @param {Number} [center] Value representing a date around which will |
|
|
* be zoomed. |
|
|
* be zoomed. |
|
|
*/ |
|
|
*/ |
|
|
Range.prototype.zoom = function(scale, center, delta) { |
|
|
|
|
|
|
|
|
Range.prototype.zoom = function(scale, center, delta, event) { |
|
|
// if centerDate is not provided, take it half between start Date and end Date
|
|
|
// if centerDate is not provided, take it half between start Date and end Date
|
|
|
if (center == null) { |
|
|
if (center == null) { |
|
|
center = (this.start + this.end) / 2; |
|
|
center = (this.start + this.end) / 2; |
|
@ -708,7 +723,7 @@ Range.prototype.zoom = function(scale, center, delta) { |
|
|
newEnd = safeEnd; |
|
|
newEnd = safeEnd; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.setRange(newStart, newEnd, false, true); |
|
|
|
|
|
|
|
|
this.setRange(newStart, newEnd, false, true, event); |
|
|
|
|
|
|
|
|
this.startToFront = false; // revert to default
|
|
|
this.startToFront = false; // revert to default
|
|
|
this.endToFront = true; // revert to default
|
|
|
this.endToFront = true; // revert to default
|
|
@ -749,7 +764,7 @@ Range.prototype.moveTo = function(moveTo) { |
|
|
var newStart = this.start - diff; |
|
|
var newStart = this.start - diff; |
|
|
var newEnd = this.end - diff; |
|
|
var newEnd = this.end - diff; |
|
|
|
|
|
|
|
|
this.setRange(newStart, newEnd); |
|
|
|
|
|
|
|
|
this.setRange(newStart, newEnd, false, true, event); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
module.exports = Range; |
|
|
module.exports = Range; |