From 51867db83d47910f694db856291ce30add0fb97e Mon Sep 17 00:00:00 2001 From: peacechen Date: Fri, 26 Jun 2020 17:22:46 -0500 Subject: [PATCH] Fix scrollable nav arrows at min/maxDate edges (#202). --- src/Scroller.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Scroller.js b/src/Scroller.js index 131df13..b765342 100644 --- a/src/Scroller.js +++ b/src/Scroller.js @@ -97,11 +97,11 @@ export default class CalendarScroller extends Component { // Scroll right, guarding against end index. scrollRight = () => { - const endIndex = this.state.visibleStartIndex + this.state.numVisibleItems; - if (endIndex === (this.state.numDays - 1)) { + const newIndex = this.state.visibleStartIndex + this.state.numVisibleItems; + if (newIndex >= (this.state.numDays - 1)) { + this.rlv.scrollToEnd(true); // scroll to the very end, including padding return; } - const newIndex = Math.min(endIndex, this.state.numDays - 1 - this.state.numVisibleItems); this.rlv.scrollToIndex(newIndex, true); } @@ -193,10 +193,12 @@ export default class CalendarScroller extends Component { { const visStart = visibleStartDate && visibleStartDate.clone(); const visEnd = visibleEndDate && visibleEndDate.clone(); - updateMonthYear && updateMonthYear(visStart, visEnd); onWeekChanged && onWeekChanged(visStart, visEnd); } + // Always update weekstart/end for WeekSelectors. + updateMonthYear && updateMonthYear(visibleStartDate, visibleEndDate); + if (visibleStartIndex === 0) { this.shiftDaysBackward(visibleStartDate); } else {