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.
- package/components/Schedule.astro +25 -0
- package/package.json +1 -1
|
@@ -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