Initial commit
This commit is contained in:
21
node_modules/framer-motion/dist/es/utils/array.mjs
generated
vendored
Normal file
21
node_modules/framer-motion/dist/es/utils/array.mjs
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
function addUniqueItem(arr, item) {
|
||||
if (arr.indexOf(item) === -1)
|
||||
arr.push(item);
|
||||
}
|
||||
function removeItem(arr, item) {
|
||||
const index = arr.indexOf(item);
|
||||
if (index > -1)
|
||||
arr.splice(index, 1);
|
||||
}
|
||||
// Adapted from array-move
|
||||
function moveItem([...arr], fromIndex, toIndex) {
|
||||
const startIndex = fromIndex < 0 ? arr.length + fromIndex : fromIndex;
|
||||
if (startIndex >= 0 && startIndex < arr.length) {
|
||||
const endIndex = toIndex < 0 ? arr.length + toIndex : toIndex;
|
||||
const [item] = arr.splice(fromIndex, 1);
|
||||
arr.splice(endIndex, 0, item);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
export { addUniqueItem, moveItem, removeItem };
|
||||
Reference in New Issue
Block a user