mirror of
https://github.com/vinta/awesome-python.git
synced 2026-04-11 14:21:45 +08:00
feat(ux): smooth-scroll hero CTA without updating URL hash
Add a data-scroll-to attribute to the hero 'Browse the List' anchor and a JS handler that calls scrollIntoView instead of letting the browser follow the href, so the URL hash is never written. Respects prefers-reduced-motion. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
8e360e82b7
commit
eb5b37daf5
@ -44,6 +44,17 @@ function initRevealSections() {
|
||||
|
||||
initRevealSections();
|
||||
|
||||
// Smooth scroll without hash in URL
|
||||
document.querySelectorAll("[data-scroll-to]").forEach(function (link) {
|
||||
link.addEventListener("click", function (e) {
|
||||
var target = document.getElementById(link.dataset.scrollTo);
|
||||
if (!target) return;
|
||||
e.preventDefault();
|
||||
var motion = window.matchMedia("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth";
|
||||
target.scrollIntoView({ behavior: motion });
|
||||
});
|
||||
});
|
||||
|
||||
// Pause hero animations when scrolled out of view
|
||||
(function () {
|
||||
const hero = document.querySelector(".hero");
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
</p>
|
||||
|
||||
<div class="hero-actions">
|
||||
<a href="#library-index" class="hero-action hero-action-primary"
|
||||
<a href="#library-index" class="hero-action hero-action-primary" data-scroll-to="library-index"
|
||||
>Browse the List</a
|
||||
>
|
||||
<a
|
||||
|
||||
Loading…
Reference in New Issue
Block a user