@ -1118,15 +1118,7 @@ ItemSet.prototype._onDrag = function (event) {
if ( 'group' in props ) {
// drag from one group to another
var group = ItemSet . groupFromTarget ( event ) ;
if ( group && group . groupId != props . item . data . group ) {
var oldGroup = props . item . parent ;
oldGroup . remove ( props . item ) ;
oldGroup . order ( ) ;
group . add ( props . item ) ;
group . order ( ) ;
props . item . data . group = group . groupId ;
}
_moveToGroup ( props . item , group ) ;
}
} ) ;
@ -1139,6 +1131,24 @@ ItemSet.prototype._onDrag = function (event) {
}
} ;
/ * *
* Move an item to another group
* @ param { Item } item
* @ param { Group } group
* @ private
* /
function _moveToGroup ( item , group ) {
if ( group && group . groupId != item . data . group ) {
var oldGroup = item . parent ;
oldGroup . remove ( item ) ;
oldGroup . order ( ) ;
group . add ( item ) ;
group . order ( ) ;
item . data . group = group . groupId ;
}
}
/ * *
* End of dragging selected items
* @ param { Event } event
@ -1151,7 +1161,9 @@ ItemSet.prototype._onDragEnd = function (event) {
me = this ,
dataset = this . itemsData . getDataSet ( ) ;
this . touchParams . itemProps . forEach ( function ( props ) {
var itemProps = this . touchParams . itemProps ;
this . touchParams . itemProps = null ;
itemProps . forEach ( function ( props ) {
var id = props . item . id ,
itemData = me . itemsData . get ( id , me . itemOptions ) ;
@ -1183,6 +1195,10 @@ ItemSet.prototype._onDragEnd = function (event) {
// restore original values
if ( 'start' in props ) props . item . data . start = props . start ;
if ( 'end' in props ) props . item . data . end = props . end ;
if ( 'group' in props && props . item . data . group != props . group ) {
var group = me . groups [ props . group ] ;
_moveToGroup ( props . item , group ) ;
}
me . stackDirty = true ; // force re-stacking of all items next redraw
me . body . emitter . emit ( 'change' ) ;
@ -1190,7 +1206,6 @@ ItemSet.prototype._onDragEnd = function (event) {
} ) ;
}
} ) ;
this . touchParams . itemProps = null ;
// apply the changes to the data (if there are changes)
if ( changes . length ) {