Skip to content

Commit

Permalink
Fix scrollable nav arrows at min/maxDate edges (#202).
Browse files Browse the repository at this point in the history
  • Loading branch information
peacechen committed Jun 26, 2020
1 parent ee3fa18 commit 51867db
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Scroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 51867db

Please sign in to comment.