From 0dfdd04a20c98bd9b6bedca8ae59d083c24d2637 Mon Sep 17 00:00:00 2001 From: Tony Yang Date: Fri, 5 Feb 2021 01:21:22 +0800 Subject: [PATCH] [Fix] scrollspy detection & default hightlight --- src/components/news/ScrollSpyDirective.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/news/ScrollSpyDirective.ts b/src/components/news/ScrollSpyDirective.ts index 914f2cb..5797b30 100644 --- a/src/components/news/ScrollSpyDirective.ts +++ b/src/components/news/ScrollSpyDirective.ts @@ -8,10 +8,10 @@ const ScrollSpyDirective: DirectiveOptions = { selectors = binding.value.selectors; // highlight first element - el.querySelector(`[href="${location.hash || selectors[0] || ''}"]`)?.classList.toggle('active', true); + el.querySelector(`[href="${selectors[0] || ''}"]`)?.classList.toggle('active', true); const config = { - rootMargin: '-10% 0px -80% 0px', + rootMargin: '-5% 0px -85% 0px', threshold: 0 };