Skip to content

Commit fa60a81

Browse files
committed
Fix tab switching: force animation restart on mode change
The mode-fade-in CSS animation wasn't replaying when toggling between Charge Now and Book a Slot because the browser caches completed animations. Fix: remove .active from both panels, force a reflow via offsetWidth read, then add .active to the target panel.
1 parent ab03f7a commit fa60a81

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

apps-script/script_v3.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,8 +1597,14 @@
15971597
document.querySelectorAll('.mobile-tab').forEach((btn) => {
15981598
btn.classList.toggle('active', btn.dataset.mode === mode);
15991599
});
1600-
document.getElementById('mode-now').classList.toggle('active', mode === 'now');
1601-
document.getElementById('mode-reserve').classList.toggle('active', mode === 'reserve');
1600+
var modeNow = document.getElementById('mode-now');
1601+
var modeReserve = document.getElementById('mode-reserve');
1602+
// Remove active from both, force reflow, then add to target — restarts CSS animation
1603+
modeNow.classList.remove('active');
1604+
modeReserve.classList.remove('active');
1605+
var target = (mode === 'now') ? modeNow : modeReserve;
1606+
void target.offsetWidth; // force reflow to restart animation
1607+
target.classList.add('active');
16021608
clearSelection();
16031609
if (mode === 'reserve' && state.board) {
16041610
updateReservationUI(state.board);

apps-script/styles_v3.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -775,9 +775,7 @@
775775

776776
.mode.active {
777777
display: block;
778-
opacity: 0;
779-
transform: translateY(8px);
780-
animation: mode-fade-in 200ms ease both;
778+
animation: mode-fade-in 200ms ease forwards;
781779
}
782780

783781
.reserve-header {

0 commit comments

Comments
 (0)