Browse Source

Implemented ctrl+click and shift+click to select multiple items

css_transitions
josdejong 10 years ago
parent
commit
fd951bef92
3 changed files with 10 additions and 3 deletions
  1. +2
    -1
      HISTORY.md
  2. +1
    -1
      docs/timeline.html
  3. +7
    -1
      src/timeline/Timeline.js

+ 2
- 1
HISTORY.md View File

@ -9,6 +9,7 @@ http://visjs.org
- Items can be dragged, added, and removed.
- Implemented options `selectable`, `editable`.
- Added events when dragging the custom time bar.
- Multiple items can be selected using ctrl+click or shift+click.
### DataSet
@ -21,7 +22,7 @@ http://visjs.org
- Implemented functions `on` and `off` to create event listeners for events
`rangechange`, `rangechanged`, and `select`.
- Impelmented function `select` to get and set the selected items.
- Implemented function `select` to get and set the selected items.
- Items can be selected by clicking them, muti-select by holding them.
- Fixed non working `start` and `end` options.

+ 1
- 1
docs/timeline.html View File

@ -483,7 +483,7 @@ var options = {
<td>selectable</td>
<td>Boolean</td>
<td>true</td>
<td>If true, the items on the timeline can be selected.</td>
<td>If true, the items on the timeline can be selected. Multiple items can be selected by long pressing them, or by using ctrl+click or shift+click. The event <code>select</code> is fired each time the selection has changed (see section <a href="#Events">Events</a>).</td>
</tr>
<tr>

+ 7
- 1
src/timeline/Timeline.js View File

@ -64,7 +64,6 @@ function Timeline (container, items, options) {
this.controller.add(this.rootPanel);
// single select (or unselect) when tapping an item
// TODO: implement ctrl+click
this.controller.on('tap', this._onSelectItem.bind(this));
// multi select when holding mouse/touch, or on ctrl+click
@ -442,6 +441,13 @@ Timeline.prototype.getSelection = function getSelection() {
Timeline.prototype._onSelectItem = function (event) {
if (!this.options.selectable) return;
var ctrlKey = event.gesture.srcEvent && event.gesture.srcEvent.ctrlKey;
var shiftKey = event.gesture.srcEvent && event.gesture.srcEvent.shiftKey;
if (ctrlKey || shiftKey) {
this._onMultiSelectItem(event);
return;
}
var item = ItemSet.itemFromTarget(event);
var selection = item ? [item.id] : [];

Loading…
Cancel
Save