Skip to content

Commit 4960cc0

Browse files
authored
Use CSS transitions for highlight animation
2 parents 73a9d64 + e1746ac commit 4960cc0

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

index.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,12 @@ function calculateKcal($protein, $carbs, $fat)
351351
.meal-button:active {
352352
transform: translateY(0);
353353
}
354+
.meal-row {
355+
transition: background-color 0.5s ease;
356+
}
357+
.meal-row.highlight {
358+
background-color: #fef3c7 !important;
359+
}
354360
</style>
355361
</head>
356362

@@ -597,7 +603,8 @@ class="w-full px-4 py-3 border border-stone-300 rounded-lg text-stone-700 focus:
597603
$existingRow.data('count', response.groupCount);
598604
$existingRow.attr('data-count', response.groupCount);
599605
// Flash animation to show update
600-
$existingRow.css('background-color', '#fef3c7').animate({backgroundColor: 'transparent'}, 500);
606+
$existingRow.addClass('highlight');
607+
setTimeout(() => $existingRow.removeClass('highlight'), 500);
601608
} else {
602609
// Create new meal row
603610
const newRow = `
@@ -686,7 +693,8 @@ function bindMealRowEvents() {
686693
$row.data('count', newCount);
687694
$row.attr('data-count', newCount);
688695
// Flash animation to show update
689-
$row.css('background-color', '#fef3c7').animate({backgroundColor: 'transparent'}, 500);
696+
$row.addClass('highlight');
697+
setTimeout(() => $row.removeClass('highlight'), 500);
690698
}
691699
}
692700
},

0 commit comments

Comments
 (0)