From 13cf9f7c25492972bdcd16cbb24b6232843104f8 Mon Sep 17 00:00:00 2001 From: antri Date: Sun, 28 Apr 2024 16:49:24 +0530 Subject: [PATCH] fix: impored scroll margins --- app/[locale]/student-activities/scroll-aware-section.tsx | 3 ++- components/scrolling-nav.tsx | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/[locale]/student-activities/scroll-aware-section.tsx b/app/[locale]/student-activities/scroll-aware-section.tsx index c59867d4..f51c04b3 100644 --- a/app/[locale]/student-activities/scroll-aware-section.tsx +++ b/app/[locale]/student-activities/scroll-aware-section.tsx @@ -12,7 +12,8 @@ const ScrollAwareSection = ({ location: string; }) => { const { ref } = useIntersectionObserver({ - threshold: 0.5, + rootMargin: '0px 0px -90% 0px', + threshold: 0.1, onChange: (isIntersecting) => { if (!isIntersecting) return; window.history.replaceState(null, '', `#${location}`); diff --git a/components/scrolling-nav.tsx b/components/scrolling-nav.tsx index 2b683502..55b2652e 100644 --- a/components/scrolling-nav.tsx +++ b/components/scrolling-nav.tsx @@ -26,7 +26,13 @@ const ScrollingNav = ({ variant="ghost" active={hash === href} > - setHash(href)}> + { + (event.target as HTMLButtonElement).blur(); // to be removed, focus styles overrides both active and normal styles on the button causing visual bug + setHash(href); + }} + > {label}