shift-org / shift-docs

Shift2Bikes: website and calendar for shift and pedalpalooza
https://shift2bikes.org
Other
22 stars 16 forks source link

calendar: Link day label in calendar grid view to scroll the event list to the chosen day #190

Open carrythebanner opened 5 years ago

carrythebanner commented 5 years ago

FullCalendar, the library we're using for the grid view, has an option to make each date label clickable. The default implementation is to load that day in the grid's day view, but we could also make it scroll the page to that day's rides in the event list (similar to the classic cal's month view).

Docs: https://fullcalendar.io/docs/date-nav-links

carrythebanner commented 4 years ago

I looked into adding a custom handler with navLinkDayClick option, to scroll the list to the chosen date. I got a start on it, but it needed some more tweaking to work properly so I fell back on FullCalendar's default behavior.

For future reference, I tried this:

navLinkDayClick: function(date) {
  var dateString = moment(date).format("YYYY-MM-DD");
  var heading = document.querySelectorAll("div[data-date='" + dateString + "']")[0];
  heading.scrollIntoView();
}

Needs two improvements at least: