Skip to content

Commit

Permalink
Restored smooth scrolling, and added code to simply not scroll to the…
Browse files Browse the repository at this point in the history
… next year or previous year if

    newYear > maxYear || newYear < minYear
is true
  • Loading branch information
TyroneAEM committed Aug 15, 2024
1 parent 4471320 commit a125c9b
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions scripts/program-calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit a125c9b

Please sign in to comment.