Browse Source

fixed item dragging offset in the x direction

v3_develop
Alex de Mulder 10 years ago
parent
commit
eb09734ca4
3 changed files with 25932 additions and 25962 deletions
  1. +25927
    -25942
      dist/vis.js
  2. +0
    -16
      lib/timeline/Core.js
  3. +5
    -4
      lib/timeline/component/ItemSet.js

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


+ 0
- 16
lib/timeline/Core.js View File

@ -624,22 +624,6 @@ Core.prototype.getCurrentTime = function() {
// TODO: move this function to Range // TODO: move this function to Range
Core.prototype._toTime = function(x) { Core.prototype._toTime = function(x) {
return DateUtil.toTime(this.body, this.range, x, this.props.center.width); return DateUtil.toTime(this.body, this.range, x, this.props.center.width);
//var startDate = new Date(this.options.hide.start).getTime();
//var endDate = new Date(this.options.hide.end).getTime();
//var duration = endDate - startDate;
//if (!(startDate >= this.range.start && endDate < this.range.end)) {
// duration = 0;
//}
//
//var conversion = this.range.conversion(this.props.center.width, duration);
//var time = new Date(x / conversion.scale + conversion.offset);
//
//if (time >= endDate && startDate >= this.range.start && endDate < this.range.end) {
// time -= duration;
//}
//
//
//return time;
}; };
/** /**

+ 5
- 4
lib/timeline/component/ItemSet.js View File

@ -1100,17 +1100,18 @@ ItemSet.prototype._onDrag = function (event) {
if (this.touchParams.itemProps) { if (this.touchParams.itemProps) {
var me = this; var me = this;
var snap = this.body.util.snap || null; var snap = this.body.util.snap || null;
var xOffset = this.body.dom.root.offsetLeft + this.body.domProps.left.width;
// move // move
this.touchParams.itemProps.forEach(function (props) { this.touchParams.itemProps.forEach(function (props) {
var newProps = {}; var newProps = {};
if ('start' in props && !('end' in props)) { // only start in props if ('start' in props && !('end' in props)) { // only start in props
var start = me.body.util.toTime(event.gesture.center.clientX)
var start = me.body.util.toTime(event.gesture.center.clientX - xOffset);
newProps.start = snap ? snap(start) : start; newProps.start = snap ? snap(start) : start;
} }
else if ('start' in props) { // start and 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 current = me.body.util.toTime(event.gesture.center.clientX - xOffset);
var initial = me.body.util.toTime(props.initialX - xOffset);
var offset = current - initial; var offset = current - initial;
var start = new Date(props.start + offset); var start = new Date(props.start + offset);
var end = new Date(props.end + offset); var end = new Date(props.end + offset);
@ -1119,7 +1120,7 @@ ItemSet.prototype._onDrag = function (event) {
newProps.end = snap ? snap(end) : end; newProps.end = snap ? snap(end) : end;
} }
else if ('end' in props) { // only end in props else if ('end' in props) { // only end in props
var end = me.body.util.toTime(event.gesture.center.clientX);
var end = me.body.util.toTime(event.gesture.center.clientX - xOffset);
newProps.end = snap ? snap(end) : end; newProps.end = snap ? snap(end) : end;
} }

Loading…
Cancel
Save