|
@ -8,6 +8,7 @@ var BoxItem = require('./item/BoxItem'); |
|
|
var PointItem = require('./item/PointItem'); |
|
|
var PointItem = require('./item/PointItem'); |
|
|
var RangeItem = require('./item/RangeItem'); |
|
|
var RangeItem = require('./item/RangeItem'); |
|
|
var BackgroundItem = require('./item/BackgroundItem'); |
|
|
var BackgroundItem = require('./item/BackgroundItem'); |
|
|
|
|
|
var DateUtil = require('../DateUtil'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var UNGROUPED = '__ungrouped__'; // reserved group id for ungrouped items
|
|
|
var UNGROUPED = '__ungrouped__'; // reserved group id for ungrouped items
|
|
@ -1036,18 +1037,17 @@ ItemSet.prototype._onDragStart = function (event) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var item = this.touchParams.item || null, |
|
|
|
|
|
me = this, |
|
|
|
|
|
props; |
|
|
|
|
|
|
|
|
var item = this.touchParams.item || null; |
|
|
|
|
|
var me = this; |
|
|
|
|
|
var props = {}; |
|
|
|
|
|
|
|
|
|
|
|
props.initialX = event.gesture.center.clientX; |
|
|
if (item && item.selected) { |
|
|
if (item && item.selected) { |
|
|
var dragLeftItem = event.target.dragLeftItem; |
|
|
var dragLeftItem = event.target.dragLeftItem; |
|
|
var dragRightItem = event.target.dragRightItem; |
|
|
var dragRightItem = event.target.dragRightItem; |
|
|
|
|
|
|
|
|
if (dragLeftItem) { |
|
|
if (dragLeftItem) { |
|
|
props = { |
|
|
|
|
|
item: dragLeftItem |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
props.item = dragLeftItem; |
|
|
|
|
|
|
|
|
if (me.options.editable.updateTime) { |
|
|
if (me.options.editable.updateTime) { |
|
|
props.start = item.data.start.valueOf(); |
|
|
props.start = item.data.start.valueOf(); |
|
@ -1059,9 +1059,7 @@ ItemSet.prototype._onDragStart = function (event) { |
|
|
this.touchParams.itemProps = [props]; |
|
|
this.touchParams.itemProps = [props]; |
|
|
} |
|
|
} |
|
|
else if (dragRightItem) { |
|
|
else if (dragRightItem) { |
|
|
props = { |
|
|
|
|
|
item: dragRightItem |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
props.item = dragRightItem; |
|
|
|
|
|
|
|
|
if (me.options.editable.updateTime) { |
|
|
if (me.options.editable.updateTime) { |
|
|
props.end = item.data.end.valueOf(); |
|
|
props.end = item.data.end.valueOf(); |
|
@ -1075,9 +1073,7 @@ ItemSet.prototype._onDragStart = function (event) { |
|
|
else { |
|
|
else { |
|
|
this.touchParams.itemProps = this.getSelection().map(function (id) { |
|
|
this.touchParams.itemProps = this.getSelection().map(function (id) { |
|
|
var item = me.items[id]; |
|
|
var item = me.items[id]; |
|
|
var props = { |
|
|
|
|
|
item: item |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
props.item = item; |
|
|
|
|
|
|
|
|
if (me.options.editable.updateTime) { |
|
|
if (me.options.editable.updateTime) { |
|
|
if ('start' in item.data) props.start = item.data.start.valueOf(); |
|
|
if ('start' in item.data) props.start = item.data.start.valueOf(); |
|
@ -1103,23 +1099,27 @@ ItemSet.prototype._onDragStart = function (event) { |
|
|
ItemSet.prototype._onDrag = function (event) { |
|
|
ItemSet.prototype._onDrag = function (event) { |
|
|
if (this.touchParams.itemProps) { |
|
|
if (this.touchParams.itemProps) { |
|
|
var me = this; |
|
|
var me = this; |
|
|
var range = this.body.range; |
|
|
|
|
|
var snap = this.body.util.snap || null; |
|
|
var snap = this.body.util.snap || null; |
|
|
var deltaX = event.gesture.deltaX; |
|
|
|
|
|
var scale = (this.props.width / (range.end - range.start)); |
|
|
|
|
|
var offset = deltaX / scale; |
|
|
|
|
|
|
|
|
|
|
|
// move
|
|
|
// move
|
|
|
this.touchParams.itemProps.forEach(function (props) { |
|
|
this.touchParams.itemProps.forEach(function (props) { |
|
|
var newProps = {}; |
|
|
var newProps = {}; |
|
|
|
|
|
|
|
|
if ('start' in props) { |
|
|
|
|
|
var start = new Date(props.start + offset); |
|
|
|
|
|
|
|
|
if ('start' in props && !('end' in props)) { // only start in props
|
|
|
|
|
|
var start = me.body.util.toTime(event.gesture.center.clientX) |
|
|
newProps.start = snap ? snap(start) : start; |
|
|
newProps.start = snap ? snap(start) : start; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if ('end' in props) { |
|
|
|
|
|
|
|
|
else if ('start' in props) { // start and end in props
|
|
|
|
|
|
var current = me.body.util.toTime(event.gesture.center.clientX); |
|
|
|
|
|
var initial = me.body.util.toTime(props.initialX); |
|
|
|
|
|
var offset = current - initial; |
|
|
|
|
|
var start = new Date(props.start + offset); |
|
|
var end = new Date(props.end + offset); |
|
|
var end = new Date(props.end + 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); |
|
|
newProps.end = snap ? snap(end) : end; |
|
|
newProps.end = snap ? snap(end) : end; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|