From a125c9b87ab08905ed9beffa822fee7cad8e6631 Mon Sep 17 00:00:00 2001 From: Tyrone Tse Date: Thu, 15 Aug 2024 15:03:47 -0500 Subject: [PATCH] Restored smooth scrolling, and added code to simply not scroll to the next year or previous year if newYear > maxYear || newYear < minYear is true --- scripts/program-calendar.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/scripts/program-calendar.js b/scripts/program-calendar.js index 872dec3..565056a 100644 --- a/scripts/program-calendar.js +++ b/scripts/program-calendar.js @@ -353,13 +353,10 @@ function changePeriod(event) { } // Prevent the year from going beyond the maximum or minimum year - if (newYear > maxYear) { - newYear = maxYear; - newQuarter = 4; // If max year, set to the last quarter - } else if (newYear < minYear) { - newYear = minYear; - newQuarter = 1; // If min year, set to the first quarter + if (newYear > maxYear || newYear < minYear) { + return; } + newPeriod = { 'year': newYear, 'quarter': newQuarter }; refreshCalendar(newPeriod, view); } @@ -630,12 +627,11 @@ function scrollToPosition(element, scrollPct) { const maxScrollLeft = element.scrollWidth; const scrollAmt = (maxScrollLeft) * (scrollPct / 100); element.scrollTo({ - left: scrollAmt, - behavior: 'auto' + left: scrollAmt, // Replace with desired position + behavior: 'smooth' // Optional: for smooth scrolling }); } - function calculateScroll(type, viewStartYear, displayYear, displayQuarter, numYears) { const yearDiff = displayYear - viewStartYear; const yearWidthOffsetPct = (((yearDiff / numYears)) * 100);