maverick-wave-astro 1.0.0 → 1.1.0

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.
@@ -57,4 +57,29 @@ import '../styles/schedule.css';
57
57
  : 'mw-calendar-today';
58
58
  day.classList.toggle(mark, day.dataset.day === today);
59
59
  });
60
+
61
+ // The browser jumps to the anchor before the promotion bar, late fonts and
62
+ // styles take their room, which leaves the target under the bar. Reload and
63
+ // back keep their own position, a visitor who already scrolls keeps theirs.
64
+ const navigation = performance.getEntriesByType('navigation')[0] as
65
+ PerformanceNavigationTiming | undefined;
66
+ const target =
67
+ location.hash && navigation?.type === 'navigate'
68
+ ? document.getElementById(decodeURIComponent(location.hash.slice(1)))
69
+ : null;
70
+ if (target) {
71
+ let scrolled = false;
72
+ for (const type of ['wheel', 'touchstart', 'keydown']) {
73
+ addEventListener(type, () => (scrolled = true), {
74
+ once: true,
75
+ passive: true,
76
+ });
77
+ }
78
+ const jump = () => {
79
+ if (!scrolled) target.scrollIntoView({ behavior: 'instant' });
80
+ };
81
+ jump();
82
+ document.fonts.ready.then(jump);
83
+ addEventListener('load', jump, { once: true });
84
+ }
60
85
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maverick-wave-astro",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Shared frame for static Astro homepages built with MaverickWave: layout, SEO, design variants, schedule, building blocks.",
5
5
  "type": "module",
6
6
  "license": "MIT",