@allons-y/course-kit 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -284,8 +284,8 @@
284
284
 
285
285
  <script>
286
286
  /**
287
- * Marks the month on screen in the row with `aria-current="location"`: the month of the week block that crosses a line just below the
288
- * row (or, in the gap between two weeks, the next one); before the first week reaches it the first month, after the last week the last month. Sets `--schedule-bar-height`
287
+ * Marks the month on screen in the row with `aria-current="location"`: the month of the last week block whose top has reached the line where an
288
+ * anchor lands it, below the row; before the first week reaches it the first month, at the foot of the page the last month. Sets `--schedule-bar-height`
289
289
  * for the page's scroll-padding while the row is sticky. It changes no size and runs no animation.
290
290
  */
291
291
  (() => {
@@ -298,12 +298,12 @@
298
298
  /** The month of a week: the latest month whose range holds it, so a week spanning two months reads as the second, where its link points. */
299
299
  const monthOf = (number) => range.findLast(({ first, last }) => number >= first && number <= last) ?? range.at(-1);
300
300
  const mark = () => {
301
- const line = Math.max(0, bar.getBoundingClientRect().bottom) + 8;
302
301
  const shown = weeks.filter((week) => !week.hidden);
303
302
  if (!shown.length) return;
304
- // The first week that is not wholly above the line: the one crossing it, or the next one when the line is in the gap between two,
305
- // and the first week while the header is still on screen. After the last week, the last month.
306
- const week = shown.find((candidate) => candidate.getBoundingClientRect().bottom > line);
303
+ // Where an anchor lands a week's top: below the row, by the page's scroll-padding and the week's scroll-margin. The week is on screen once its top is at or above that line.
304
+ const line = (Number.parseFloat(getComputedStyle(document.documentElement).scrollPaddingTop) || 0) + (Number.parseFloat(getComputedStyle(shown[0]).scrollMarginTop) || 0) + 1;
305
+ // The last week whose top has reached the line, or the first week before any has.
306
+ const week = shown.findLast((candidate) => candidate.getBoundingClientRect().top <= line) ?? shown[0];
307
307
  // A page scrolled to its foot can leave the last week below the line: then the last month is the one on screen.
308
308
  const bottomed = window.scrollY > 0 && window.scrollY + window.innerHeight >= document.documentElement.scrollHeight - 2;
309
309
  const current = week && !bottomed ? monthOf(Number(week.id.slice(5))) : range.at(-1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allons-y/course-kit",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Shared layouts, components, styles and build helpers for Eleventy course sites.",
5
5
  "license": "MPL-2.0",
6
6
  "author": "Cassondra Roberts <castastrophe@users.noreply.github.com> (https://allons-y.studio)",