Wanderxx / vue-fullcalendar

vue calendar fullCalendar. no jquery required. Schedule events management
https://wanderxx.github.io/vue-fullcalendar/
1.51k stars 387 forks source link

changeMonth doesn't include the current date of the month it changed to. #5

Closed anlek closed 8 years ago

anlek commented 8 years ago

I've started working with vue-fullcalendar and during switching of the date, I found an issue of I didn't know what month I was switching to. The changeMonth attributes are start and end which give you the first date in the calendar and the last date. In most cases, it did not include the month it was currently on.

(example: If I'm looking at September/2016, the start date is Aug 29th and end date is Oct 10th, but the month I need to know is September 1st, 2016)

Maybe it be a great idea to return changeMonth with (start, end, current) dates. Where current is the first day of the month you changed to. Just a thought.

anlek commented 8 years ago

My current work around works but isn't pretty:

// In my ready callback on my component I have:
this.$on('changeMonth', this.updateMonth)
// In methods
updateMonth (startDate, endDate) {
  startDate = moment(startDate, 'YYYY-MM-DD')
  endDate = moment(endDate, 'YYYY-MM-DD')
  // Working date is now an average of the two dates, 
  // I have yet to find a case this doesn't work but it's still
  // a lot of extra computation, where vue-fullcalendar knows
  // the current day
  this.workingDate = moment.unix(
    (startDate.unix() + endDate.unix()) / 2
  )
}

I also tried to send it the prop currentDate and sync it but for some reason it didn't work (even though it seemed like it should have).

If there is another way to make this happen, please let me know.

Wanderxx commented 8 years ago

Hey, I have added current as 3rd arguments in event changeMonth. You can check out both from npm and git.

anlek commented 8 years ago

Wow, thanks! That saves me time!