Browse Source

Fixed #401: width of range items not always being maintained when moving due to snapping to nice dates

v3_develop
jos 10 years ago
parent
commit
1d7982f591
2 changed files with 15 additions and 3 deletions
  1. +2
    -0
      HISTORY.md
  2. +13
    -3
      lib/timeline/component/ItemSet.js

+ 2
- 0
HISTORY.md View File

@ -21,6 +21,8 @@ http://visjs.org
- Implemented option `timeAxis: {scale: string, step: number}` to set a
fixed scale.
- Fixed width of range items not always being maintained when moving due to
snapping to nice dates.
## 2015-01-16, version 3.9.1

+ 13
- 3
lib/timeline/component/ItemSet.js View File

@ -1130,8 +1130,15 @@ ItemSet.prototype._onDragStart = function (event) {
};
if (me.options.editable.updateTime) {
if ('start' in item.data) props.start = item.data.start.valueOf();
if ('end' in item.data) props.end = item.data.end.valueOf();
if ('start' in item.data) {
props.start = item.data.start.valueOf();
if ('end' in item.data) {
// we store a duration here in order not to change the width
// of the item when moving it.
props.duration = item.data.end.valueOf() - props.start;
}
}
}
if (me.options.editable.updateGroup) {
if ('group' in item.data) props.group = item.data.group;
@ -1151,7 +1158,7 @@ ItemSet.prototype._onDragStart = function (event) {
* @private
*/
ItemSet.prototype._onDrag = function (event) {
event.preventDefault()
event.preventDefault();
if (this.touchParams.itemProps) {
var me = this;
@ -1174,6 +1181,9 @@ ItemSet.prototype._onDrag = function (event) {
var end = new Date(props.end + offset);
newProps.end = snap ? snap(end) : end;
}
else if ('duration' in props) {
newProps.end = new Date(newProps.start.valueOf() + props.duration);
}
if ('group' in props) {
// drag from one group to another

Loading…
Cancel
Save