This repository was archived by the owner on Jul 26, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed
Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @payhereinc/react-native-week-view" ,
3- "version" : " 0.6.7 " ,
3+ "version" : " 0.6.8 " ,
44 "description" : " Week View Calendar for React Native" ,
55 "main" : " index.js" ,
66 "repository" : {
Original file line number Diff line number Diff line change @@ -41,7 +41,9 @@ export default class WeekView extends Component {
4141 this . eventsGridScrollX = new Animated . Value ( 0 ) ;
4242
4343 const initialDates = this . calculatePagesDates (
44- props . selectedDate ,
44+ moment ( props . selectedDate ) . month ( ) === moment ( ) . month ( )
45+ ? moment ( ) . toDate ( )
46+ : props . selectedDate ,
4547 props . numberOfDays ,
4648 props . weekStartsOn ,
4749 props . prependMostRecent ,
@@ -70,8 +72,20 @@ export default class WeekView extends Component {
7072 setLocale ( this . props . locale ) ;
7173 }
7274 if ( this . props . numberOfDays !== prevProps . numberOfDays ) {
75+ const prevMonth =
76+ prevProps . numberOfDays === 7
77+ ? moment ( this . state . currentMoment ) . endOf ( 'week' ) . month ( )
78+ : moment ( this . state . currentMoment ) . month ( ) ;
79+ const currentMoment =
80+ moment ( ) . month ( ) !== prevMonth
81+ ? moment ( this . state . currentMoment )
82+ . endOf ( 'week' )
83+ . startOf ( 'month' )
84+ . toDate ( )
85+ : moment ( ) . toDate ( ) ;
86+
7387 const initialDates = this . calculatePagesDates (
74- this . state . currentMoment ,
88+ currentMoment ,
7589 this . props . numberOfDays ,
7690 this . props . weekStartsOn ,
7791 this . props . prependMostRecent ,
@@ -320,7 +334,7 @@ export default class WeekView extends Component {
320334 ) => {
321335 const initialDates = [ ] ;
322336 const centralDate = moment ( currentMoment ) ;
323- if ( numberOfDays === 7 || fixedHorizontally ) {
337+ if ( numberOfDays !== 1 && ( numberOfDays === 7 || fixedHorizontally ) ) {
324338 centralDate . subtract (
325339 // Ensure centralDate is before currentMoment
326340 ( centralDate . day ( ) + 7 - weekStartsOn ) % 7 ,
You can’t perform that action at this time.
0 commit comments