[Fix] scrollspy detection & default hightlight

This commit is contained in:
Tony Yang
2021-02-05 01:21:22 +08:00
parent abf7c93f48
commit 0dfdd04a20

View File

@@ -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
};