calendar icon indicating copy to clipboard operation
calendar copied to clipboard

Time grid mobile styling

Open MaCleodWalker opened this issue 1 year ago • 9 comments

Is it possible to make the the column a set width and the left time bar sticky in the resourceTimeGridDay and resourceTimeGridWeek views for better mobile experience? Similar to Google calendar's 3 day mobile view.

MaCleodWalker avatar Jan 24 '24 20:01 MaCleodWalker

Can you provide a screenshot, please? I looked at the web version of Google Calendar on my mobile device, but didn't see anything similar there.

vkurko avatar Jan 25 '24 06:01 vkurko

Screenshot_20240127_120119_Calendar.jpg

MaCleodWalker avatar Jan 27 '24 19:01 MaCleodWalker

Thank you. So the left time bar does not scroll, but always remains in the visibility area.

I don't currently have a ready solution, but it might be possible to do it in CSS. I'll try later.

vkurko avatar Jan 29 '24 10:01 vkurko

One solution to this is e.g.

    .ec-time-grid.ec-week-view {
      .ec-day {
        min-width: 300px;
      }

      .ec-days {
        overflow: auto;
      }
    }

// From https://stackoverflow.com/a/31084338
<script>

    var scrollers = document.querySelectorAll('.ec-time-grid.ec-week-view .ec-days');

    var scrollerDivs = Array.prototype.filter.call(scrollers, function (testElement) {
      return testElement.nodeName === 'DIV';
    });

    function scrollAll(scrollLeft) {
      scrollerDivs.forEach(function (element, index, array) {
        element.scrollLeft = scrollLeft;
      });
    }

    scrollerDivs.forEach(function (element, index, array) {
      element.addEventListener('scroll', function (e) {
        scrollAll(e.target.scrollLeft);
      });
    });

</script>

Don't even need to use display: sticky on the sidebar elements. Slight limitations are that scrollbars are exposed, and moving to the next/previous week does not scroll back the left. Can probably be handled with a handler somewhere but haven't tried yet.

mrweiner avatar Feb 28 '24 03:02 mrweiner

Looks like scrollbars can be hidden with like:

.ec-days {
  overflow: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;

  &::-webkit-scrollbar {
    display: none;
  }
}

mrweiner avatar Feb 28 '24 03:02 mrweiner

How are you adding these classes to the component?

MaCleodWalker avatar May 07 '24 19:05 MaCleodWalker

@MaCleodWalker for me, I'm fairly sure the classes are available by default.

mrweiner avatar Jul 01 '24 19:07 mrweiner

It would be so nice (and smoother scrolling) if ec-header and ec-body had an enclosing div around them. Then, no need for the JavaScript to make them scroll together.

josteinSkeyl avatar Aug 14 '24 14:08 josteinSkeyl

It would be so nice (and smoother scrolling) if ec-header and ec-body had an enclosing div around them.

The problem is that ec-body also has a vertical scroll that needs to be synchronized with the sidebar. So the enclosing div is not enough there.

There is a solution without JS, based on position: sticky, but I don't really like how the scrollbar looks in this case, which gets onto sticky elements. But perhaps in the future I will redesign it to the sticky version.

vkurko avatar Aug 15 '24 07:08 vkurko