|
1141 | 1141 | return; |
1142 | 1142 | } |
1143 | 1143 |
|
1144 | | - // Return invocation when no further action is needed in another sortable |
1145 | | - function completed() { |
1146 | | - if (activeSortable) { |
1147 | | - // Set ghost class to new sortable's ghost class |
1148 | | - _toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : activeSortable.options.ghostClass, false); |
1149 | | - _toggleClass(dragEl, options.ghostClass, true); |
1150 | | - } |
| 1144 | + // Return invocation when dragEl is inserted (or completed) |
| 1145 | + function completed(insertion) { |
| 1146 | + if (insertion) { |
| 1147 | + if (isOwner) { |
| 1148 | + activeSortable._hideClone(); |
| 1149 | + } else { |
| 1150 | + activeSortable._showClone(_this); |
| 1151 | + } |
1151 | 1152 |
|
1152 | | - if (putSortable !== _this && _this !== Sortable.active) { |
1153 | | - putSortable = _this; |
1154 | | - } else if (_this === Sortable.active) { |
1155 | | - putSortable = null; |
| 1153 | + if (activeSortable) { |
| 1154 | + // Set ghost class to new sortable's ghost class |
| 1155 | + _toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : activeSortable.options.ghostClass, false); |
| 1156 | + _toggleClass(dragEl, options.ghostClass, true); |
| 1157 | + } |
| 1158 | + |
| 1159 | + if (putSortable !== _this && _this !== Sortable.active) { |
| 1160 | + putSortable = _this; |
| 1161 | + } else if (_this === Sortable.active) { |
| 1162 | + putSortable = null; |
| 1163 | + } |
| 1164 | + |
| 1165 | + // Animation |
| 1166 | + dragRect && _this._animate(dragRect, dragEl); |
| 1167 | + target && targetRect && _this._animate(targetRect, target); |
1156 | 1168 | } |
1157 | 1169 |
|
1158 | 1170 |
|
|
1188 | 1200 |
|
1189 | 1201 | // target is dragEl or target is animated |
1190 | 1202 | if (!!_closest(evt.target, null, dragEl, true) || target.animated) { |
1191 | | - return completed(); |
| 1203 | + return completed(false); |
1192 | 1204 | } |
1193 | 1205 |
|
1194 | 1206 | if (target !== dragEl) { |
|
1221 | 1233 | rootEl.appendChild(dragEl); |
1222 | 1234 | } |
1223 | 1235 |
|
1224 | | - return completed(); |
| 1236 | + return completed(true); |
1225 | 1237 | } |
1226 | 1238 |
|
1227 | 1239 | var elLastChild = _lastChild(el); |
|
1248 | 1260 | realDragElRect = null; |
1249 | 1261 |
|
1250 | 1262 | changed(); |
1251 | | - this._animate(dragRect, dragEl); |
1252 | | - target && this._animate(targetRect, target); |
1253 | | - return completed(); |
| 1263 | + return completed(true); |
1254 | 1264 | } |
1255 | 1265 | } |
1256 | 1266 | else if (target && target !== dragEl && target.parentNode === el) { |
|
1292 | 1302 | lastMode = 'swap'; |
1293 | 1303 | } else { |
1294 | 1304 | // Insert at position |
1295 | | - direction = _getInsertDirection(target, options); |
| 1305 | + direction = _getInsertDirection(target); |
1296 | 1306 | lastMode = 'insert'; |
1297 | 1307 | } |
1298 | | - if (direction === 0) return completed(); |
| 1308 | + if (direction === 0) return completed(false); |
1299 | 1309 |
|
1300 | 1310 | realDragElRect = null; |
1301 | 1311 | lastTarget = target; |
|
1344 | 1354 | } |
1345 | 1355 | changed(); |
1346 | 1356 |
|
1347 | | - !differentLevel && this._animate(targetRect, target); |
1348 | | - this._animate(dragRect, dragEl); |
1349 | | - |
1350 | | - return completed(); |
| 1357 | + return completed(true); |
1351 | 1358 | } |
1352 | 1359 | } |
1353 | 1360 |
|
1354 | 1361 | if (el.contains(dragEl)) { |
1355 | | - return completed(); |
| 1362 | + return completed(false); |
1356 | 1363 | } |
1357 | 1364 | } |
1358 | 1365 |
|
|
2063 | 2070 | mouseOnAxis > targetS1 + (targetLength * (1 - swapThreshold) / 2) && |
2064 | 2071 | mouseOnAxis < targetS2 - (targetLength * (1 - swapThreshold) / 2) |
2065 | 2072 | ) { |
2066 | | - return ((mouseOnAxis > targetS1 + targetLength / 2) ? -1 : 1); |
| 2073 | + return _getInsertDirection(target); |
2067 | 2074 | } |
2068 | 2075 | } |
2069 | 2076 | } |
|
2088 | 2095 | * Gets the direction dragEl must be swapped relative to target in order to make it |
2089 | 2096 | * seem that dragEl has been "inserted" into that element's position |
2090 | 2097 | * @param {HTMLElement} target The target whose position dragEl is being inserted at |
2091 | | - * @param {Object} options options of the parent sortable |
2092 | 2098 | * @return {Number} Direction dragEl must be swapped |
2093 | 2099 | */ |
2094 | | - function _getInsertDirection(target, options) { |
2095 | | - var dragElIndex = _index(dragEl, options.draggable), |
2096 | | - targetIndex = _index(target, options.draggable); |
| 2100 | + function _getInsertDirection(target) { |
| 2101 | + var dragElIndex = _index(dragEl), |
| 2102 | + targetIndex = _index(target); |
2097 | 2103 |
|
2098 | 2104 | if (dragElIndex < targetIndex) { |
2099 | 2105 | return 1; |
|
0 commit comments