From 274a2d7d9d7d6623a77d14305743c0081a63ba58 Mon Sep 17 00:00:00 2001 From: jos Date: Mon, 2 Mar 2015 10:08:08 +0100 Subject: [PATCH] Fixed #664: end of item not restored when canceling a move event --- HISTORY.md | 1 + lib/timeline/component/ItemSet.js | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 8a71f54c..86a7249c 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -23,6 +23,7 @@ http://visjs.org - Fixed not property initializing with a DataView for groups. - Merged add custom timebar functionality, thanks @aytech! +- Fixed #664: end of item not restored when canceling a move event. ## 2015-02-11, version 3.10.0 diff --git a/lib/timeline/component/ItemSet.js b/lib/timeline/component/ItemSet.js index dd6eb87a..571e87ea 100644 --- a/lib/timeline/component/ItemSet.js +++ b/lib/timeline/component/ItemSet.js @@ -1229,8 +1229,15 @@ ItemSet.prototype._onDrag = function (event) { */ ItemSet.prototype._updateItemProps = function(item, props) { // TODO: copy all properties from props to item? (also new ones) - if ('start' in props) item.data.start = props.start; - if ('end' in props) item.data.end = props.end; + if ('start' in props) { + item.data.start = props.start; + } + if ('end' in props) { + item.data.end = props.end; + } + else if ('duration' in props) { + item.data.end = new Date(props.start.valueOf() + props.duration); + } if ('group' in props && item.data.group != props.group) { this._moveToGroup(item, props.group) }