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 - Fixed #654: removed unnecessary minimum height for groups, takes the
height of the group label as minimum height now. height of the group label as minimum height now.
- Fixed #708: detecting wrong group when page is scrolled. - 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 ## 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) { if (dragLeftItem) {
props = { props = {
item: dragLeftItem, item: dragLeftItem,
initialX: event.gesture.center.pageX
initialX: event.gesture.center.clientX
}; };
if (me.options.editable.updateTime) { if (me.options.editable.updateTime) {
@ -1130,7 +1130,7 @@ ItemSet.prototype._onDragStart = function (event) {
else if (dragRightItem) { else if (dragRightItem) {
props = { props = {
item: dragRightItem, item: dragRightItem,
initialX: event.gesture.center.pageX
initialX: event.gesture.center.clientX
}; };
if (me.options.editable.updateTime) { if (me.options.editable.updateTime) {
@ -1147,7 +1147,7 @@ ItemSet.prototype._onDragStart = function (event) {
var item = me.items[id]; var item = me.items[id];
var props = { var props = {
item: item, item: item,
initialX: event.gesture.center.pageX
initialX: event.gesture.center.clientX
}; };
if (me.options.editable.updateTime) { if (me.options.editable.updateTime) {
@ -1214,7 +1214,7 @@ ItemSet.prototype._onDragStartAddItem = function (event) {
var props = { var props = {
item: newItem, item: newItem,
end: end.valueOf(), end: end.valueOf(),
initialX: event.gesture.center.pageX
initialX: event.gesture.center.clientX
}; };
this.touchParams.itemProps = [props]; this.touchParams.itemProps = [props];
@ -1241,7 +1241,7 @@ ItemSet.prototype._onDrag = function (event) {
// move // move
this.touchParams.itemProps.forEach(function (props) { this.touchParams.itemProps.forEach(function (props) {
var newProps = {}; 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 initial = me.body.util.toTime(props.initialX - xOffset);
var offset = current - initial; var offset = current - initial;
@ -1522,7 +1522,9 @@ ItemSet.prototype._onMultiSelectItem = function (event) {
var start = _item.data.start; var start = _item.data.start;
var end = (_item.data.end !== undefined) ? _item.data.end : 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 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 * @return {Group | null} group
*/ */
ItemSet.prototype.groupFromTarget = function(event) { 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++) { for (var i = 0; i < this.groupIds.length; i++) {
var groupId = this.groupIds[i]; var groupId = this.groupIds[i];
var group = this.groups[groupId]; var group = this.groups[groupId];
var foreground = group.dom.foreground; var foreground = group.dom.foreground;
var top = util.getAbsoluteTop(foreground); var top = util.getAbsoluteTop(foreground);
if (pageY > top && pageY < top + foreground.offsetHeight) {
if (clientY > top && clientY < top + foreground.offsetHeight) {
return group; return group;
} }
if (this.options.orientation === 'top') { if (this.options.orientation === 'top') {
if (i === this.groupIds.length - 1 && pageY > top) {
if (i === this.groupIds.length - 1 && clientY > top) {
return group; return group;
} }
} }
else { else {
if (i === 0 && pageY < top + foreground.offset) {
if (i === 0 && clientY < top + foreground.offset) {
return group; return group;
} }
} }

Loading…
Cancel
Save