Browse Source

- Added byUser flag to options of the rangechange and rangechanged event.

v3_develop
Alex de Mulder 9 years ago
parent
commit
e9d6c9897a
4 changed files with 8392 additions and 8374 deletions
  1. +4
    -0
      HISTORY.md
  2. +8370
    -8364
      dist/vis.js
  3. +4
    -2
      docs/timeline.html
  4. +14
    -8
      lib/timeline/Range.js

+ 4
- 0
HISTORY.md View File

@ -13,6 +13,10 @@ http://visjs.org
- Improved drawing of arrowheads on smooth curves. #349
- Caught case where click originated on external DOM element and drag progressed to vis.
### Timeline
- Added byUser flag to options of the rangechange and rangechanged event.
## 20145-01-09, version 3.8.0
### General

+ 8370
- 8364
dist/vis.js
File diff suppressed because it is too large
View File


+ 4
- 2
docs/timeline.html View File

@ -1053,24 +1053,26 @@ timeline.off('select', onSelect);
<tr>
<td>rangechange</td>
<td>Fired repeatedly when the user is dragging the timeline window.
<td>Fired repeatedly when the timeline window is being changed.
</td>
<td>
<ul>
<li><code>start</code> (Number): timestamp of the current start of the window.</li>
<li><code>end</code> (Number): timestamp of the current end of the window.</li>
<li><code>byUser</code> (Boolean): change happened because of user drag/zoom.</li>
</ul>
</td>
</tr>
<tr>
<td>rangechanged</td>
<td>Fired once after the user has dragged the timeline window.
<td>Fired once after the timeline window has been changed.
</td>
<td>
<ul>
<li><code>start</code> (Number): timestamp of the current start of the window.</li>
<li><code>end</code> (Number): timestamp of the current end of the window.</li>
<li><code>byUser</code> (Boolean): change happened because of user drag/zoom.</li>
</ul>
</td>
</tr>

+ 14
- 8
lib/timeline/Range.js View File

@ -112,9 +112,13 @@ function validateDirection (direction) {
* If animate is a number, the
* number is taken as duration
* Default duration is 500 ms.
* @param {Boolean} [byUser=false]
*
*/
Range.prototype.setRange = function(start, end, animate) {
Range.prototype.setRange = function(start, end, animate, byUser) {
if (byUser !== true) {
byUser = false;
}
var _start = start != undefined ? util.convert(start, 'Date').valueOf() : null;
var _end = end != undefined ? util.convert(end, 'Date').valueOf() : null;
this._cancelAnimation();
@ -139,12 +143,12 @@ Range.prototype.setRange = function(start, end, animate) {
DateUtil.updateHiddenDates(me.body, me.options.hiddenDates);
anyChanged = anyChanged || changed;
if (changed) {
me.body.emitter.emit('rangechange', {start: new Date(me.start), end: new Date(me.end)});
me.body.emitter.emit('rangechange', {start: new Date(me.start), end: new Date(me.end), byUser:byUser});
}
if (done) {
if (anyChanged) {
me.body.emitter.emit('rangechanged', {start: new Date(me.start), end: new Date(me.end)});
me.body.emitter.emit('rangechanged', {start: new Date(me.start), end: new Date(me.end), byUser:byUser});
}
}
else {
@ -161,7 +165,7 @@ Range.prototype.setRange = function(start, end, animate) {
var changed = this._applyRange(_start, _end);
DateUtil.updateHiddenDates(this.body, this.options.hiddenDates);
if (changed) {
var params = {start: new Date(this.start), end: new Date(this.end)};
var params = {start: new Date(this.start), end: new Date(this.end), byUser:byUser};
this.body.emitter.emit('rangechange', params);
this.body.emitter.emit('rangechanged', params);
}
@ -412,7 +416,8 @@ Range.prototype._onDrag = function (event) {
// fire a rangechange event
this.body.emitter.emit('rangechange', {
start: new Date(this.start),
end: new Date(this.end)
end: new Date(this.end),
byUser: true
});
};
@ -437,7 +442,8 @@ Range.prototype._onDragEnd = function (event) {
// fire a rangechanged event
this.body.emitter.emit('rangechanged', {
start: new Date(this.start),
end: new Date(this.end)
end: new Date(this.end),
byUser: true
});
};
@ -552,7 +558,7 @@ Range.prototype._onPinch = function (event) {
newEnd = safeEnd;
}
this.setRange(newStart, newEnd);
this.setRange(newStart, newEnd, false, true);
this.startToFront = false; // revert to default
this.endToFront = true; // revert to default
@ -629,7 +635,7 @@ Range.prototype.zoom = function(scale, center, delta) {
newEnd = safeEnd;
}
this.setRange(newStart, newEnd);
this.setRange(newStart, newEnd, false, true);
this.startToFront = false; // revert to default
this.endToFront = true; // revert to default

Loading…
Cancel
Save