@@ -41,6 +41,7 @@ class Calendar extends PureComponent {
4141 this . renderMonthAndYear = this . renderMonthAndYear . bind ( this ) ;
4242 this . updatePreview = this . updatePreview . bind ( this ) ;
4343 this . estimateMonthSize = this . estimateMonthSize . bind ( this ) ;
44+ this . handleScroll = this . handleScroll . bind ( this ) ;
4445 this . dateOptions = { locale : props . locale } ;
4546 this . styles = generateStyles ( [ coreStyles , props . classNames ] ) ;
4647 this . listSizeCache = { } ;
@@ -132,8 +133,8 @@ class Calendar extends PureComponent {
132133 }
133134 }
134135 changeShownDate ( value , mode = 'set' ) {
135- const { focusedDate} = this . state ;
136- const { onShownDateChange, minDate, maxDate} = this . props ;
136+ const { focusedDate } = this . state ;
137+ const { onShownDateChange, minDate, maxDate } = this . props ;
137138 const modeMapper = {
138139 monthOffset : ( ) => addMonths ( focusedDate , value ) ,
139140 setMonth : ( ) => setMonth ( focusedDate , value ) ,
@@ -142,11 +143,23 @@ class Calendar extends PureComponent {
142143 } ;
143144 const newDate = min ( [ max ( [ modeMapper [ mode ] ( ) , minDate ] ) , maxDate ] ) ;
144145 this . focusToDate ( newDate , this . props , false ) ;
145- onShownDateChange && onShownDateChange ( newDate )
146+ onShownDateChange && onShownDateChange ( newDate ) ;
146147 }
147148 handleRangeFocusChange ( rangesIndex , rangeItemIndex ) {
148149 this . props . onRangeFocusChange && this . props . onRangeFocusChange ( [ rangesIndex , rangeItemIndex ] ) ;
149150 }
151+ handleScroll ( ) {
152+ const { onShownDateChange, minDate } = this . props ;
153+ const visibleMonths = this . list . getVisibleRange ( ) ;
154+ // prevent scroll jump with wrong visible value
155+ if ( visibleMonths [ 0 ] === undefined ) return ;
156+ const visibleMonth = addMonths ( minDate , visibleMonths [ 0 ] || 0 ) ;
157+ const isFocusedToDifferent = ! isSameMonth ( visibleMonth , this . state . focusedDate ) ;
158+ if ( isFocusedToDifferent ) {
159+ this . setState ( { focusedDate : visibleMonth } ) ;
160+ onShownDateChange && onShownDateChange ( visibleMonth ) ;
161+ }
162+ }
150163 renderMonthAndYear ( focusedDate , changeShownDate , props ) {
151164 const { showMonthArrow, locale, minDate, maxDate } = props ;
152165 const upperYearLimit = maxDate . getFullYear ( ) ;
@@ -355,14 +368,7 @@ class Calendar extends PureComponent {
355368 width : scrollArea . calendarWidth + 11 ,
356369 height : scrollArea . calendarHeight + 11 ,
357370 } }
358- onScroll = { ( ) => {
359- const visibleMonths = this . list . getVisibleRange ( ) ;
360- // prevent scroll jump with wrong visible value
361- if ( visibleMonths [ 0 ] === undefined ) return ;
362- const visibleMonth = addMonths ( minDate , visibleMonths [ 0 ] || 0 ) ;
363- const isFocusedToDifferent = ! isSameMonth ( visibleMonth , focusedDate ) ;
364- if ( isFocusedToDifferent ) this . setState ( { focusedDate : visibleMonth } ) ;
365- } } >
371+ onScroll = { this . handleScroll } >
366372 < ReactList
367373 length = { differenceInCalendarMonths (
368374 endOfMonth ( maxDate ) ,
0 commit comments