diff --git a/src/framework/ui/calendar/baseCalendar.component.tsx b/src/framework/ui/calendar/baseCalendar.component.tsx index ab87b7565..1ac6f508f 100644 --- a/src/framework/ui/calendar/baseCalendar.component.tsx +++ b/src/framework/ui/calendar/baseCalendar.component.tsx @@ -155,9 +155,8 @@ export abstract class BaseCalendarComponent extends React.Component { - const yearStart: D = this.dateService.getYearStart(this.min); this.setState({ - visibleDate: this.dateService.addMonth(yearStart, index), + visibleDate: this.dateService.addMonth(this.min, index), }); }; @@ -174,27 +173,20 @@ export abstract class BaseCalendarComponent extends React.Component { - this.onCalendarPagerMove(-1); - }; - - private onCalendarPagerRight = (): void => { - this.onCalendarPagerMove(1); - }; + private onHeaderNavigationLeftPress = (): void => { + const pagerRef: React.RefObject> = this.getCurrentPagerRef(); - private onCalendarPagerMove = (step: number): void => { - const ref: React.RefObject> = this.getCurrentPagerRef(); - const index: number = this.getCalendarPagerIndex(); - - this.onCalendarPagerMoveStart(ref, index, step); + pagerRef.current.scrollToIndex({ + index: pagerRef.current.props.selectedIndex - 1, + animated: true, + }); }; - private onCalendarPagerMoveStart = (ref: React.RefObject>, - index: number, - step: number): void => { + private onHeaderNavigationRightPress = (): void => { + const pagerRef: React.RefObject> = this.getCurrentPagerRef(); - ref.current.scrollToIndex({ - index: index + step, + pagerRef.current.scrollToIndex({ + index: pagerRef.current.props.selectedIndex + 1, animated: true, }); }; @@ -524,8 +516,8 @@ export abstract class BaseCalendarComponent extends React.Component ); }; diff --git a/src/framework/ui/calendar/calendar.component.tsx b/src/framework/ui/calendar/calendar.component.tsx index e5b8467ec..928ccf0fe 100644 --- a/src/framework/ui/calendar/calendar.component.tsx +++ b/src/framework/ui/calendar/calendar.component.tsx @@ -60,6 +60,8 @@ export type CalendarElement = React.ReactElement>; * * @overview-example CalendarFilter * + * @overview-example CalendarBounds + * * @overview-example CalendarCustomLocale * * @example CalendarMoment diff --git a/src/framework/ui/calendar/components/calendarHeader.component.tsx b/src/framework/ui/calendar/components/calendarHeader.component.tsx index f69048707..6b18936e2 100644 --- a/src/framework/ui/calendar/components/calendarHeader.component.tsx +++ b/src/framework/ui/calendar/components/calendarHeader.component.tsx @@ -20,8 +20,8 @@ interface ComponentProps extends ViewProps { iconStyle?: ImageStyle; lateralNavigationAllowed: boolean; onTitlePress?: () => void; - onRight?: () => void; - onLeft?: () => void; + onNavigationLeftPress?: () => void; + onNavigationRightPress?: () => void; } export type CalendarHeaderProps = ComponentProps; @@ -64,14 +64,14 @@ export class CalendarHeader extends React.Component { appearance='ghost' // @ts-ignore icon={this.renderLeftIcon} - onPress={this.props.onLeft} + onPress={this.props.onNavigationLeftPress} />