Browse Source

Fixed #733: background items being selected on shift+click.

v3_develop
jos 9 years ago
parent
commit
f7a257c522
2 changed files with 13 additions and 10 deletions
  1. +1
    -0
      HISTORY.md
  2. +12
    -10
      lib/timeline/component/ItemSet.js

+ 1
- 0
HISTORY.md View File

@ -14,6 +14,7 @@ http://visjs.org
- Fixed #654: removed unnecessary minimum height for groups, takes the
height of the group label as minimum height now.
- Fixed #708: detecting wrong group when page is scrolled.
- Fixed #733: background items being selected on shift+click.
## 2015-03-05, version 3.11.0

+ 12
- 10
lib/timeline/component/ItemSet.js View File

@ -1115,7 +1115,7 @@ ItemSet.prototype._onDragStart = function (event) {
if (dragLeftItem) {
props = {
item: dragLeftItem,
initialX: event.gesture.center.pageX
initialX: event.gesture.center.clientX
};
if (me.options.editable.updateTime) {
@ -1130,7 +1130,7 @@ ItemSet.prototype._onDragStart = function (event) {
else if (dragRightItem) {
props = {
item: dragRightItem,
initialX: event.gesture.center.pageX
initialX: event.gesture.center.clientX
};
if (me.options.editable.updateTime) {
@ -1147,7 +1147,7 @@ ItemSet.prototype._onDragStart = function (event) {
var item = me.items[id];
var props = {
item: item,
initialX: event.gesture.center.pageX
initialX: event.gesture.center.clientX
};
if (me.options.editable.updateTime) {
@ -1214,7 +1214,7 @@ ItemSet.prototype._onDragStartAddItem = function (event) {
var props = {
item: newItem,
end: end.valueOf(),
initialX: event.gesture.center.pageX
initialX: event.gesture.center.clientX
};
this.touchParams.itemProps = [props];
@ -1241,7 +1241,7 @@ ItemSet.prototype._onDrag = function (event) {
// move
this.touchParams.itemProps.forEach(function (props) {
var newProps = {};
var current = me.body.util.toTime(event.gesture.center.pageX - xOffset);
var current = me.body.util.toTime(event.gesture.center.clientX - xOffset);
var initial = me.body.util.toTime(props.initialX - xOffset);
var offset = current - initial;
@ -1522,7 +1522,9 @@ ItemSet.prototype._onMultiSelectItem = function (event) {
var start = _item.data.start;
var end = (_item.data.end !== undefined) ? _item.data.end : start;
if (start >= range.min && end <= range.max) {
if (start >= range.min &&
end <= range.max &&
!(_item instanceof BackgroundItem)) {
selection.push(_item.id); // do not use id but item.id, id itself is stringified
}
}
@ -1607,23 +1609,23 @@ ItemSet.prototype.itemFromTarget = function(event) {
* @return {Group | null} group
*/
ItemSet.prototype.groupFromTarget = function(event) {
var pageY = event.gesture ? event.gesture.center.pageY : event.pageY;
var clientY = event.gesture ? event.gesture.center.clientY : event.clientY;
for (var i = 0; i < this.groupIds.length; i++) {
var groupId = this.groupIds[i];
var group = this.groups[groupId];
var foreground = group.dom.foreground;
var top = util.getAbsoluteTop(foreground);
if (pageY > top && pageY < top + foreground.offsetHeight) {
if (clientY > top && clientY < top + foreground.offsetHeight) {
return group;
}
if (this.options.orientation === 'top') {
if (i === this.groupIds.length - 1 && pageY > top) {
if (i === this.groupIds.length - 1 && clientY > top) {
return group;
}
}
else {
if (i === 0 && pageY < top + foreground.offset) {
if (i === 0 && clientY < top + foreground.offset) {
return group;
}
}

Loading…
Cancel
Save