Browse Source

Fixed #708: wrong group detected when page is scrolled.

v3_develop
Jos de Jong 9 years ago
parent
commit
0b90860fd9
2 changed files with 10 additions and 9 deletions
  1. +1
    -0
      HISTORY.md
  2. +9
    -9
      lib/timeline/component/ItemSet.js

+ 1
- 0
HISTORY.md View File

@ -13,6 +13,7 @@ http://visjs.org
- Orientation can now be configured separately for axis and items. - Orientation can now be configured separately for axis and items.
- 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.
## 2015-03-05, version 3.11.0 ## 2015-03-05, version 3.11.0

+ 9
- 9
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.clientX
initialX: event.gesture.center.pageX
}; };
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.clientX
initialX: event.gesture.center.pageX
}; };
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.clientX
initialX: event.gesture.center.pageX
}; };
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.clientX
initialX: event.gesture.center.pageX
}; };
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.clientX - xOffset);
var current = me.body.util.toTime(event.gesture.center.pageX - 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;
@ -1607,23 +1607,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 clientY = event.gesture ? event.gesture.center.clientY : event.clientY;
var pageY = event.gesture ? event.gesture.center.pageY : event.pageY;
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 (clientY > top && clientY < top + foreground.offsetHeight) {
if (pageY > top && pageY < top + foreground.offsetHeight) {
return group; return group;
} }
if (this.options.orientation === 'top') { if (this.options.orientation === 'top') {
if (i === this.groupIds.length - 1 && clientY > top) {
if (i === this.groupIds.length - 1 && pageY > top) {
return group; return group;
} }
} }
else { else {
if (i === 0 && clientY < top + foreground.offset) {
if (i === 0 && pageY < top + foreground.offset) {
return group; return group;
} }
} }

Loading…
Cancel
Save