Skip to content

Commit 196b4cf

Browse files
committed
Display ignored items grey when Eager animation completes
1 parent b4aff80 commit 196b4cf

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/components/ArrayEvaluationDemo.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ interface Step {
2525
narrationDescription: string;
2626
explode?: boolean;
2727
skipRemaining?: boolean;
28-
untaken?: boolean;
2928
}
3029

3130
interface ExplosionParticle {
@@ -58,10 +57,8 @@ const ArrayEvaluationDemo: React.FC = ({
5857
const animationRef = useRef<number | null>(null);
5958

6059
const EXPLOSION_DURATION = 500;
61-
// const ANIMATION_STEP = 0.2;
62-
const ANIMATION_STEP = 0.15; // Reduced from 0.2 to slow down animation
63-
const FRAME_DURATION = 16; // roughly 60fps
64-
60+
const ANIMATION_STEP = 0.15;
61+
const FRAME_DURATION = 16;
6562
const MAX_PROGRESS = 150;
6663
const isEven = (n: number): boolean => n % 2 === 0;
6764

@@ -106,9 +103,9 @@ const ArrayEvaluationDemo: React.FC = ({
106103
from: 2,
107104
to: 2,
108105
progress: 144,
109-
untaken: true,
106+
skipRemaining: true,
110107
narrationTitle: 'Done!',
111-
narrationDescription: '3 items taken',
108+
narrationDescription: 'Remaining items not taken',
112109
},
113110
],
114111
lazy: [
@@ -328,7 +325,12 @@ const ArrayEvaluationDemo: React.FC = ({
328325
let skipRemainingItems = false;
329326

330327
const newPositions = dots.map((dot, i) => {
331-
if (type === 'lazy') {
328+
if (type === 'eager') {
329+
const lastStep = currentSteps[currentSteps.length - 1];
330+
if (lastStep.skipRemaining && progress >= lastStep.progress) {
331+
skipRemainingItems = isEven(i) && ![0, 2, 4].includes(i);
332+
}
333+
} else if (type === 'lazy') {
332334
const skipStep = currentSteps.find(
333335
(s) => s.skipRemaining && progress >= s.progress,
334336
);
@@ -424,7 +426,6 @@ const ArrayEvaluationDemo: React.FC = ({
424426
const deltaTime = currentTime - lastTime;
425427

426428
if (deltaTime >= FRAME_DURATION) {
427-
// Only update if enough time has passed
428429
setProgress((prev) => {
429430
const next = Math.min(prev + ANIMATION_STEP, MAX_PROGRESS);
430431
if (next >= MAX_PROGRESS) {

0 commit comments

Comments
 (0)