aurelia-dragula
Version:
An aurelia compatible version of Dragula
18 lines (16 loc) • 497 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.moveBefore = moveBefore;
function moveBefore(array, itemMatcherFn, siblingMatcherFn) {
var removedItem = remove(array, itemMatcherFn);
var nextIndex = array.findIndex(siblingMatcherFn);
array.splice(nextIndex >= 0 ? nextIndex : array.length, 0, removedItem);
}
function remove(array, matcherFn) {
var index = array.findIndex(matcherFn);
if (index >= 0) {
return array.splice(index, 1)[0];
}
}