oficina / calendar Public

Clone
git clone https://amadan.net/oficina/calendar

Plain git — no account needed to clone.

Download

Download this file

1// Calendar's hour grids begin at midnight in the DOM so their geometry and
2// keyboard targets remain honest. On a fresh page load, bring the working
3// day into view without animation; browser history restoration remains in
4// charge on Back/Forward.
5addEventListener("DOMContentLoaded", () => {
6 if (performance.getEntriesByType("navigation")[0]?.type === "back_forward") return;
7 const hour = document.querySelector("[cal-working-hour]");
8 const scroller = hour && hour.closest("[cal-grid], [cal-week-scroll]");
9 if (!scroller) return;
10 requestAnimationFrame(() => {
11 const top = hour.getBoundingClientRect().top - scroller.getBoundingClientRect().top;
12 scroller.scrollTop = Math.max(0, scroller.scrollTop + top - 72);
13 });
14});
15