This commit is contained in:
gpt-engineer-app[bot] 2025-12-01 07:06:42 +00:00
parent b694b38558
commit 5d4d87b3a1

View file

@ -58,49 +58,31 @@ const FerrersRogersRamanujan = () => {
setIsAnimating(true);
};
// Animation effect
// Animation effect - traverse main diagonal only
useEffect(() => {
if (!isAnimating || committedPartition.length === 0) return;
const partition = committedPartition;
// Find the hook at current animation step
let found = false;
let hookCount = 0;
let targetRow = 0, targetCol = 0;
// Main diagonal: positions (0,0), (1,1), (2,2), ... while box exists
const row = animationStep;
const col = animationStep;
const maxRow = partition.length;
const maxCol = partition[0] || 0;
for (let d = 0; d < maxRow + maxCol && !found; d++) {
for (let r = 0; r <= d; r++) {
const c = d - r;
if (r < partition.length && c < partition[r]) {
if (hookCount === animationStep) {
targetRow = r;
targetCol = c;
found = true;
break;
}
hookCount++;
}
}
}
if (!found) {
// Animation complete
// Check if this diagonal position has a box
if (row >= partition.length || col >= partition[row]) {
// Animation complete - no more diagonal boxes
setIsAnimating(false);
setAnimatingHook(null);
return;
}
setAnimatingHook({ row: targetRow, col: targetCol });
setAnimatingHook({ row, col });
// Calculate hook size
const boxesRight = partition[targetRow] - targetCol - 1;
// Calculate hook size: boxes to the right + boxes below + 1 (the box itself)
const boxesRight = partition[row] - col - 1;
let boxesBelow = 0;
for (let r = targetRow + 1; r < partition.length; r++) {
if (partition[r] > targetCol) {
for (let r = row + 1; r < partition.length; r++) {
if (partition[r] > col) {
boxesBelow++;
} else {
break;