diff --git a/HISTORY.md b/HISTORY.md index 920c7c01..631e7b95 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -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. diff --git a/docs/timeline.html b/docs/timeline.html index 33e5beee..9b1674c6 100644 --- a/docs/timeline.html +++ b/docs/timeline.html @@ -483,7 +483,7 @@ var options = { selectable Boolean true - If true, the items on the timeline can be selected. + 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 select is fired each time the selection has changed (see section Events). diff --git a/src/timeline/Timeline.js b/src/timeline/Timeline.js index 5789b431..4d7d20b8 100644 --- a/src/timeline/Timeline.js +++ b/src/timeline/Timeline.js @@ -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] : [];