Skip to content

Commit

Permalink
Fix links on desktop
Browse files Browse the repository at this point in the history
  • Loading branch information
hanshenrik committed Nov 25, 2024
1 parent 23c0369 commit 2a5ca0d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 7 deletions.
35 changes: 28 additions & 7 deletions src/pages/historikk.astro
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ const years = [
<h1 class="text-5xl md:text-7xl">Historikk</h1>
<p>Tidligere artister på mandaljazz.</p>
<div
class="sticky top-[52px] z-10 -mx-4 md:top-[56px] md:col-span-2 md:mx-0 lg:col-span-2"
class="sticky top-[48px] z-10 -mx-4 md:col-span-2 lg:top-[56px] lg:col-span-2"
>
<ul
class="sticky top-[52px] flex flex-row items-center gap-4 overflow-x-auto bg-beige px-4 py-3 md:top-[56px] md:flex-col md:items-start md:px-0"
class="scrollbar-hidden flex flex-row items-center gap-4 overflow-x-auto bg-beige px-4 py-3"
>
{
years.map((year) => (
Expand Down Expand Up @@ -355,8 +355,29 @@ const years = [
</main>
</Layout>

<script
is:inline
async
src="//embedr.flickr.com/assets/client-code.js"
charset="utf-8"></script>
<script>
// list of elements to be observed
const targets = document.getElementsByClassName("observed");

const options = {
root: null, // null means root is viewport
rootMargin: "0px",
threshold: 0.5, // trigger callback when 50% of the element is visible
};

function callback(entries, observer) {
console.log({ document, entries, observer });
entries.forEach((entry) => {
if (entry.isIntersecting) {
document.querySelector(".active")?.classList?.remove("active");
const targetId = entry.target.id; // identify which element is visible in the viewport at 50%
console.log({ targetId });
document.querySelector(`[href="#${targetId}"]`).classList.add("active");
}
});
}

let observer = new IntersectionObserver(callback, options);

[...targets].forEach((target) => observer.observe(target));
</script>
16 changes: 16 additions & 0 deletions src/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
@tailwind components;
@tailwind utilities;

@layer utilities {
/* Chrome, Safari and Opera */
.scrollbar-hidden::-webkit-scrollbar {
display: none;
}

.scrollbar-hidden {
scrollbar-width: none; /* Firefox */
-ms-overflow-style: none; /* IE and Edge */
}
}

body {
letter-spacing: 0.05em;
hyphenate-character: "-";
Expand Down Expand Up @@ -44,6 +56,10 @@ h6 {
background-position: 0 22%;
color: theme("colors.white");
}
.link.active {
background-position: 0 22%;
color: theme("colors.white");
}

.bg-grainy-dark-blue-gradient {
background: linear-gradient(
Expand Down

0 comments on commit 2a5ca0d

Please sign in to comment.