@@ -23,7 +23,6 @@ function App() {
23
23
)
24
24
const [ pendingStep , setPendingStep ] = useState ( false )
25
25
26
- // Create a new packet for the current step
27
26
const createPacketForStep = useCallback ( ( step : number ) => {
28
27
const newPacket = getPacketForStep ( step )
29
28
if ( ! newPacket ) return null
@@ -32,7 +31,6 @@ function App() {
32
31
return newPacket
33
32
} , [ ] )
34
33
35
- // Start or continue animation
36
34
const startAnimation = useCallback ( ( ) => {
37
35
if ( currentStep >= TOTAL_STEPS ) {
38
36
setIsPlaying ( false )
@@ -64,7 +62,10 @@ function App() {
64
62
}
65
63
66
64
const handleStepForward = ( ) => {
67
- if ( currentStep < TOTAL_STEPS && ! isPlaying ) {
65
+ if ( currentStep >= TOTAL_STEPS ) return
66
+ if ( currentPacket ) {
67
+ handlePacketComplete ( ) // Instantly finish the current animation and move to the next step
68
+ } else {
68
69
setPendingStep ( true )
69
70
setInfoText ( getInfoText ( currentStep ) )
70
71
createPacketForStep ( currentStep )
@@ -83,9 +84,12 @@ function App() {
83
84
84
85
const handlePacketComplete = useCallback ( ( ) => {
85
86
setCurrentPacket ( null )
86
- if ( isPlaying || pendingStep ) {
87
+ setLayerInfo ( '' )
88
+ if ( pendingStep ) {
87
89
setCurrentStep ( ( prev ) => prev + 1 )
88
90
setPendingStep ( false )
91
+ } else if ( isPlaying ) {
92
+ setCurrentStep ( ( prev ) => prev + 1 )
89
93
}
90
94
} , [ isPlaying , pendingStep ] )
91
95
0 commit comments