Browse Source

Fixed #414: only one item being dragged when multiple items are selected.

v3_develop
jos 10 years ago
parent
commit
43bead4a77
5 changed files with 53 additions and 46 deletions
  1. +1
    -0
      HISTORY.md
  2. +21
    -18
      dist/vis.js
  3. +1
    -1
      dist/vis.map
  4. +9
    -9
      dist/vis.min.js
  5. +21
    -18
      lib/timeline/component/ItemSet.js

+ 1
- 0
HISTORY.md View File

@ -7,6 +7,7 @@ http://visjs.org
### Timeline
- Fixed height of background items when having a fixed or max height defined.
- Fixed only one item being dragged when multiple items are selected.
## 2014-10-28, version 3.6.3

+ 21
- 18
dist/vis.js View File

@ -11783,15 +11783,17 @@ return /******/ (function(modules) { // webpackBootstrap
var item = this.touchParams.item || null;
var me = this;
var props = {};
var props;
props.initialX = event.gesture.center.clientX;
if (item && item.selected) {
var dragLeftItem = event.target.dragLeftItem;
var dragRightItem = event.target.dragRightItem;
if (dragLeftItem) {
props.item = dragLeftItem;
props = {
item: dragLeftItem,
initialX: event.gesture.center.clientX
};
if (me.options.editable.updateTime) {
props.start = item.data.start.valueOf();
@ -11803,7 +11805,10 @@ return /******/ (function(modules) { // webpackBootstrap
this.touchParams.itemProps = [props];
}
else if (dragRightItem) {
props.item = dragRightItem;
props = {
item: dragRightItem,
initialX: event.gesture.center.clientX
};
if (me.options.editable.updateTime) {
props.end = item.data.end.valueOf();
@ -11817,7 +11822,10 @@ return /******/ (function(modules) { // webpackBootstrap
else {
this.touchParams.itemProps = this.getSelection().map(function (id) {
var item = me.items[id];
props.item = item;
var props = {
item: item,
initialX: event.gesture.center.clientX
};
if (me.options.editable.updateTime) {
if ('start' in item.data) props.start = item.data.start.valueOf();
@ -11849,22 +11857,17 @@ return /******/ (function(modules) { // webpackBootstrap
// move
this.touchParams.itemProps.forEach(function (props) {
var newProps = {};
if ('start' in props && !('end' in props)) { // only start in props
var start = me.body.util.toTime(event.gesture.center.clientX - xOffset);
newProps.start = snap ? snap(start) : start;
}
else if ('start' in props) { // start and end in props
var current = me.body.util.toTime(event.gesture.center.clientX - xOffset);
var initial = me.body.util.toTime(props.initialX - xOffset);
var offset = current - initial;
var start = new Date(props.start + offset);
var end = new Date(props.end + offset);
var current = me.body.util.toTime(event.gesture.center.clientX - xOffset);
var initial = me.body.util.toTime(props.initialX - xOffset);
var offset = current - initial;
if ('start' in props) {
var start = new Date(props.start + offset);
newProps.start = snap ? snap(start) : start;
newProps.end = snap ? snap(end) : end;
}
else if ('end' in props) { // only end in props
var end = me.body.util.toTime(event.gesture.center.clientX - xOffset);
if ('end' in props) {
var end = new Date(props.end + offset);
newProps.end = snap ? snap(end) : end;
}

+ 1
- 1
dist/vis.map
File diff suppressed because it is too large
View File


+ 9
- 9
dist/vis.min.js
File diff suppressed because it is too large
View File


+ 21
- 18
lib/timeline/component/ItemSet.js View File

@ -1085,15 +1085,17 @@ ItemSet.prototype._onDragStart = function (event) {
var item = this.touchParams.item || null;
var me = this;
var props = {};
var props;
props.initialX = event.gesture.center.clientX;
if (item && item.selected) {
var dragLeftItem = event.target.dragLeftItem;
var dragRightItem = event.target.dragRightItem;
if (dragLeftItem) {
props.item = dragLeftItem;
props = {
item: dragLeftItem,
initialX: event.gesture.center.clientX
};
if (me.options.editable.updateTime) {
props.start = item.data.start.valueOf();
@ -1105,7 +1107,10 @@ ItemSet.prototype._onDragStart = function (event) {
this.touchParams.itemProps = [props];
}
else if (dragRightItem) {
props.item = dragRightItem;
props = {
item: dragRightItem,
initialX: event.gesture.center.clientX
};
if (me.options.editable.updateTime) {
props.end = item.data.end.valueOf();
@ -1119,7 +1124,10 @@ ItemSet.prototype._onDragStart = function (event) {
else {
this.touchParams.itemProps = this.getSelection().map(function (id) {
var item = me.items[id];
props.item = item;
var props = {
item: item,
initialX: event.gesture.center.clientX
};
if (me.options.editable.updateTime) {
if ('start' in item.data) props.start = item.data.start.valueOf();
@ -1151,22 +1159,17 @@ ItemSet.prototype._onDrag = function (event) {
// move
this.touchParams.itemProps.forEach(function (props) {
var newProps = {};
if ('start' in props && !('end' in props)) { // only start in props
var start = me.body.util.toTime(event.gesture.center.clientX - xOffset);
newProps.start = snap ? snap(start) : start;
}
else if ('start' in props) { // start and end in props
var current = me.body.util.toTime(event.gesture.center.clientX - xOffset);
var initial = me.body.util.toTime(props.initialX - xOffset);
var offset = current - initial;
var start = new Date(props.start + offset);
var end = new Date(props.end + offset);
var current = me.body.util.toTime(event.gesture.center.clientX - xOffset);
var initial = me.body.util.toTime(props.initialX - xOffset);
var offset = current - initial;
if ('start' in props) {
var start = new Date(props.start + offset);
newProps.start = snap ? snap(start) : start;
newProps.end = snap ? snap(end) : end;
}
else if ('end' in props) { // only end in props
var end = me.body.util.toTime(event.gesture.center.clientX - xOffset);
if ('end' in props) {
var end = new Date(props.end + offset);
newProps.end = snap ? snap(end) : end;
}

Loading…
Cancel
Save