Browse Source

Fixed #550: `Timeline.redraw()` now also recalculates the size of items.

v3_develop
jos 9 years ago
parent
commit
d587c437a8
10 changed files with 24823 additions and 24755 deletions
  1. +1
    -0
      HISTORY.md
  2. +24763
    -24725
      dist/vis.js
  3. +1
    -1
      dist/vis.map
  4. +1
    -1
      dist/vis.min.css
  5. +15
    -15
      dist/vis.min.js
  6. +3
    -1
      docs/timeline.html
  7. +16
    -8
      lib/timeline/Core.js
  8. +1
    -1
      lib/timeline/Graph2d.js
  9. +11
    -1
      lib/timeline/Timeline.js
  10. +11
    -2
      lib/timeline/component/ItemSet.js

+ 1
- 0
HISTORY.md View File

@ -29,6 +29,7 @@ http://visjs.org
### Timeline ### Timeline
- `Timeline.redraw()` now also recalculates the size of items.
- Implemented option `timeAxis: {scale: string, step: number}` to set a - Implemented option `timeAxis: {scale: string, step: number}` to set a
fixed scale. fixed scale.
- Fixed width of range items not always being maintained when moving due to - Fixed width of range items not always being maintained when moving due to

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


+ 1
- 1
dist/vis.map
File diff suppressed because it is too large
View File


+ 1
- 1
dist/vis.min.css
File diff suppressed because it is too large
View File


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


+ 3
- 1
docs/timeline.html View File

@ -941,7 +941,9 @@ timeline.clear({options: true}); // clear options only
<tr> <tr>
<td>redraw()</td> <td>redraw()</td>
<td>none</td> <td>none</td>
<td>Force a redraw of the Timeline. Can be useful to manually redraw when option autoResize=false.
<td>Force a redraw of the Timeline. The size of all items will be recalculated.
Can be useful to manually redraw when option <code>autoResize=false</code> and the window
has been resized, or when the items CSS has been changed.
</td> </td>
</tr> </tr>

+ 16
- 8
lib/timeline/Core.js View File

@ -88,7 +88,7 @@ Core.prototype._create = function (container) {
this.dom.rightContainer.appendChild(this.dom.shadowTopRight); this.dom.rightContainer.appendChild(this.dom.shadowTopRight);
this.dom.rightContainer.appendChild(this.dom.shadowBottomRight); this.dom.rightContainer.appendChild(this.dom.shadowBottomRight);
this.on('rangechange', this.redraw.bind(this));
this.on('rangechange', this._redraw.bind(this));
this.on('touch', this._onTouch.bind(this)); this.on('touch', this._onTouch.bind(this));
this.on('pinch', this._onPinch.bind(this)); this.on('pinch', this._onPinch.bind(this));
this.on('dragstart', this._onDragStart.bind(this)); this.on('dragstart', this._onDragStart.bind(this));
@ -101,13 +101,13 @@ Core.prototype._create = function (container) {
if (!me._redrawTimer) { if (!me._redrawTimer) {
me._redrawTimer = setTimeout(function () { me._redrawTimer = setTimeout(function () {
me._redrawTimer = null; me._redrawTimer = null;
me.redraw();
me._redraw();
}, 0) }, 0)
} }
} }
else { else {
// redraw immediately // redraw immediately
me.redraw();
me._redraw();
} }
}); });
@ -224,7 +224,7 @@ Core.prototype.setOptions = function (options) {
} }
// redraw everything // redraw everything
this.redraw();
this._redraw();
}; };
/** /**
@ -457,10 +457,18 @@ Core.prototype.getWindow = function() {
}; };
/** /**
* Force a redraw of the Core. Can be useful to manually redraw when
* option autoResize=false
* Force a redraw. Can be overridden by implementations of Core
*/ */
Core.prototype.redraw = function() { Core.prototype.redraw = function() {
this._redraw();
};
/**
* Redraw for internal use. Redraws all components. See also the public
* method redraw.
* @protected
*/
Core.prototype._redraw = function() {
var resized = false; var resized = false;
var options = this.options; var options = this.options;
var props = this.props; var props = this.props;
@ -611,7 +619,7 @@ Core.prototype.redraw = function() {
var MAX_REDRAWS = 3; // maximum number of consecutive redraws var MAX_REDRAWS = 3; // maximum number of consecutive redraws
if (this.redrawCount < MAX_REDRAWS) { if (this.redrawCount < MAX_REDRAWS) {
this.redrawCount++; this.redrawCount++;
this.redraw();
this._redraw();
} }
else { else {
console.log('WARNING: infinite loop in redraw?'); console.log('WARNING: infinite loop in redraw?');
@ -819,7 +827,7 @@ Core.prototype._onDrag = function (event) {
if (newScrollTop != oldScrollTop) { if (newScrollTop != oldScrollTop) {
this.redraw(); // TODO: this causes two redraws when dragging, the other is triggered by rangechange already
this._redraw(); // TODO: this causes two redraws when dragging, the other is triggered by rangechange already
this.emit("verticalDrag"); this.emit("verticalDrag");
} }
}; };

+ 1
- 1
lib/timeline/Graph2d.js View File

@ -106,7 +106,7 @@ function Graph2d (container, items, groups, options) {
this.setItems(items); this.setItems(items);
} }
else { else {
this.redraw();
this._redraw();
} }
} }

+ 11
- 1
lib/timeline/Timeline.js View File

@ -111,13 +111,23 @@ function Timeline (container, items, groups, options) {
this.setItems(items); this.setItems(items);
} }
else { else {
this.redraw();
this._redraw();
} }
} }
// Extend the functionality from Core // Extend the functionality from Core
Timeline.prototype = new Core(); Timeline.prototype = new Core();
/**
* Force a redraw. The size of all items will be recalculated.
* Can be useful to manually redraw when option autoResize=false and the window
* has been resized, or when the items CSS has been changed.
*/
Timeline.prototype.redraw = function() {
this.itemSet && this.itemSet.markDirty({refreshItems: true});
this._redraw();
};
/** /**
* Set items * Set items
* @param {vis.DataSet | Array | google.visualization.DataTable | null} items * @param {vis.DataSet | Array | google.visualization.DataTable | null} items

+ 11
- 2
lib/timeline/component/ItemSet.js View File

@ -324,11 +324,20 @@ ItemSet.prototype.setOptions = function(options) {
}; };
/** /**
* Mark the ItemSet dirty so it will refresh everything with next redraw
* Mark the ItemSet dirty so it will refresh everything with next redraw.
* Optionally, all items can be marked as dirty and be refreshed.
* @param {{refreshItems: boolean}} [options]
*/ */
ItemSet.prototype.markDirty = function() {
ItemSet.prototype.markDirty = function(options) {
this.groupIds = []; this.groupIds = [];
this.stackDirty = true; this.stackDirty = true;
if (options && options.refreshItems) {
util.forEach(this.items, function (item) {
item.dirty = true;
if (item.displayed) item.redraw();
});
}
}; };
/** /**

Loading…
Cancel
Save