Time grid mobile styling
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.
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.
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.
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.
Looks like scrollbars can be hidden with like:
.ec-days {
overflow: auto;
scrollbar-width: none;
-ms-overflow-style: none;
&::-webkit-scrollbar {
display: none;
}
}
How are you adding these classes to the component?
@MaCleodWalker for me, I'm fairly sure the classes are available by default.
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.
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.