const removeFromQueue = (pos, track) => {
const refList = itemsRef.current;
const delRefEl = refList[pos];
const otherRefItems = refList.slice(pos + 1);
const updateList = Array.from(tracks);
updateList.splice(pos, 1);
gsap.to(delRefEl, {
duration: 0.5,
opacity: 0,
onComplete: tweenFinished,
onCompleteParams: [otherRefItems, pos],
});
function tweenFinished(otherItems, rIdx) {
console.log({ otherItems, rIdx });
const tl = gsap.timeline({
onComplete: onAnimationComplete,
onCompleteParams: [rIdx],
});
otherItems.forEach((item) => {
const tween = gsap.to(item, {
y: "-70",
clear: "y",
});
tl.add(tween, 0);
});
}
function onAnimationComplete() {
dispatch({
type: PLAYING_LIST_ACTIVE_TRACKS,
payload: updateList,
});
}
};