Browse Source

A fix in applying fit on initialization of the Timeline

v3_develop
jos 10 years ago
parent
commit
e7ec9a669a
2 changed files with 12 additions and 10 deletions
  1. +3
    -3
      lib/timeline/Range.js
  2. +9
    -7
      lib/timeline/Timeline.js

+ 3
- 3
lib/timeline/Range.js View File

@ -128,13 +128,13 @@ Range.prototype.setRange = function(start, end, animate) {
var now = new Date().valueOf(); var now = new Date().valueOf();
var time = now - initTime; var time = now - initTime;
var done = time > duration; var done = time > duration;
var s = done ? start : util.easeInOutQuad(time, initStart, _start, duration);
var e = done ? end : util.easeInOutQuad(time, initEnd, _end, duration);
var s = (done || _start === null) ? _start : util.easeInOutQuad(time, initStart, _start, duration);
var e = (done || _end === null) ? _end : util.easeInOutQuad(time, initEnd, _end, duration);
changed = me._applyRange(s, e); changed = me._applyRange(s, e);
anyChanged = anyChanged || changed; anyChanged = anyChanged || changed;
if (changed) { if (changed) {
me.body.emitter.emit('rangechange', {start: new Date(s), end: new Date(e)});
me.body.emitter.emit('rangechange', {start: new Date(me.start), end: new Date(me.end)});
} }
if (done) { if (done) {

+ 9
- 7
lib/timeline/Timeline.js View File

@ -132,14 +132,16 @@ Timeline.prototype.setItems = function(items) {
// set items // set items
this.itemsData = newDataSet; this.itemsData = newDataSet;
this.itemSet && this.itemSet.setItems(newDataSet); this.itemSet && this.itemSet.setItems(newDataSet);
if (initialLoad) {
if (this.options.start != undefined || this.options.end != undefined) {
var start = this.options.start != undefined ? this.options.start : null;
var end = this.options.end != undefined ? this.options.end : null;
if (initialLoad && ('start' in this.options || 'end' in this.options)) {
this.fit();
var start = ('start' in this.options) ? util.convert(this.options.start, 'Date') : null;
var end = ('end' in this.options) ? util.convert(this.options.end, 'Date') : null;
this.setWindow(start, end, false);
this.setWindow(start, end, {animate: false});
}
else {
this.fit({animate: false});
}
} }
}; };

Loading…
Cancel
Save