kthornbloom / Monthly

A jQuery based responsive calendar
http://kthornbloom.com/monthly/
Other
316 stars 108 forks source link

The selected day doesn't scroll into correct position in list view #80

Open timelapse999 opened 6 years ago

timelapse999 commented 6 years ago

When you click a day in the calendar view and get into to list view, the list doesn't scroll into correct position. (At least in Chrome 63.0.3239.132).

I found out the element offset is taken before the element becomes visible, so it will remain '0' instead of the correct value.

Here's my simple, basically one line, fix for monthly.js:

// Click A Day
    $(document.body).on("click touchstart", parent + " .monthly-day", function (event) {
        // If events, show events list
        var whichDay = $(this).data("number");
        if(options.mode === "event" && options.eventList) {
            var theList = $(parent + " .monthly-event-list"),

                              //line can end here
                  myElement = document.getElementById(uniqueId + "day" + whichDay);

                              //from the original
                      //topPos = myElement.offsetTop; 

            theList.show();
            theList.css("transform");
            theList.css("transform", "scale(1)");
            $(parent + ' .monthly-list-item[data-number="' + whichDay + '"]').show();

                        //from the original, gave offset value of '0'
            //theList.scrollTop(topPos); 

                        //fix, the only required change, gives the correct offset value
            theList.scrollTop(myElement.offsetTop);

            viewToggleButton();
            if(!options.linkCalendarToEventUrl) {
                event.preventDefault();
            }
kthornbloom commented 6 years ago

Thanks! That bug has been bugging me as well. I'll get this added soon