fix: play new particle after playback is ended
This commit is contained in:
@@ -79,6 +79,10 @@ function playbackReducer(
|
|||||||
if (action.particleCount === 0) {
|
if (action.particleCount === 0) {
|
||||||
return { currentIndex: 0, status: "idle", paused: state.paused };
|
return { currentIndex: 0, status: "idle", paused: state.paused };
|
||||||
}
|
}
|
||||||
|
if (state.status === "ended" && state.currentIndex < action.particleCount - 1) {
|
||||||
|
// New particle appended — resume and advance to it
|
||||||
|
return { ...state, currentIndex: state.currentIndex + 1, status: "playing", paused: false };
|
||||||
|
}
|
||||||
if (state.currentIndex >= action.particleCount) {
|
if (state.currentIndex >= action.particleCount) {
|
||||||
return { ...state, currentIndex: action.particleCount - 1 };
|
return { ...state, currentIndex: action.particleCount - 1 };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user