Browse Source

Fixed #86: A newly created item is now initialized with `end` property when option `type`

is `"range"` or `"rangeoverflow"`.
css_transitions
jos 10 years ago
parent
commit
cf48b7d7ca
4 changed files with 12 additions and 3 deletions
  1. +2
    -0
      HISTORY.md
  2. +1
    -1
      docs/timeline.html
  3. +5
    -0
      src/timeline/Timeline.js
  4. +4
    -2
      test/timeline.html

+ 2
- 0
HISTORY.md View File

@ -10,6 +10,8 @@ http://visjs.org
- Added function `repaint()` to force a repaint of the Timeline. - Added function `repaint()` to force a repaint of the Timeline.
- Some tweaks in snapping dragged items to nice dates. - Some tweaks in snapping dragged items to nice dates.
- Made the instance of moment.js packaged with vis.js accessibly via `vis.moment`. - Made the instance of moment.js packaged with vis.js accessibly via `vis.moment`.
- A newly created item is initialized with `end` property when option `type`
is `"range"` or `"rangeoverflow"`.
- Fixed a bug in replacing the DataSet of groups via `Timeline.setGroups(groups)`. - Fixed a bug in replacing the DataSet of groups via `Timeline.setGroups(groups)`.
- Fixed a bug when rendering the Timeline inside a hidden container. - Fixed a bug when rendering the Timeline inside a hidden container.

+ 1
- 1
docs/timeline.html View File

@ -588,7 +588,7 @@ var options = {
<td>type</td> <td>type</td>
<td>String</td> <td>String</td>
<td>'box'</td> <td>'box'</td>
<td>Specifies the type for the timeline items. Choose from 'box', 'point', 'range', and 'rangeoverflow'. Note that individual items can override this global type.
<td>Specifies the default type for the timeline items. Choose from 'box', 'point', 'range', and 'rangeoverflow'. Note that individual items can override this default type.
</td> </td>
</tr> </tr>

+ 5
- 0
src/timeline/Timeline.js View File

@ -634,6 +634,11 @@ Timeline.prototype._onAddItem = function (event) {
content: 'new item' content: 'new item'
}; };
// when default type is a range, add a default end date to the new item
if (this.options.type === 'range' || this.options.type == 'rangeoverflow') {
newItem.end = this.timeAxis.snap(this._toTime(x + this.rootPanel.width / 5));
}
var id = util.randomUUID(); var id = util.randomUUID();
newItem[this.itemsData.fieldId] = id; newItem[this.itemsData.fieldId] = id;

+ 4
- 2
test/timeline.html View File

@ -69,9 +69,11 @@
{_id: 1, content: 'item 1<br>start', start: now.clone().add('days', 4).toDate()}, {_id: 1, content: 'item 1<br>start', start: now.clone().add('days', 4).toDate()},
{_id: 2, content: 'item 2', start: now.clone().add('days', -2).toDate() }, {_id: 2, content: 'item 2', start: now.clone().add('days', -2).toDate() },
{_id: 3, content: 'item 3', start: now.clone().add('days', 2).toDate()}, {_id: 3, content: 'item 3', start: now.clone().add('days', 2).toDate()},
{_id: 4, content: 'item 4',
{
_id: 4, content: 'item 4',
start: now.clone().add('days', 0).toDate(), start: now.clone().add('days', 0).toDate(),
end: now.clone().add('days', 7).toDate()},
end: now.clone().add('days', 7).toDate()
},
{_id: 5, content: 'item 5', start: now.clone().add('days', 9).toDate(), type:'point'}, {_id: 5, content: 'item 5', start: now.clone().add('days', 9).toDate(), type:'point'},
{_id: 6, content: 'item 6', start: now.clone().add('days', 11).toDate()} {_id: 6, content: 'item 6', start: now.clone().add('days', 11).toDate()}
]); ]);

Loading…
Cancel
Save