From 65020cee65f7d64a0e6e06bb2900e3185b07a022 Mon Sep 17 00:00:00 2001 From: Taly Date: Mon, 25 Jul 2022 16:28:42 +0300 Subject: [PATCH] update offsets --- src/frontend/js/classes/table-of-content.js | 8 +++++--- src/frontend/styles/components/header.pcss | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/frontend/js/classes/table-of-content.js b/src/frontend/js/classes/table-of-content.js index 86a879c..b4900fb 100644 --- a/src/frontend/js/classes/table-of-content.js +++ b/src/frontend/js/classes/table-of-content.js @@ -122,10 +122,12 @@ export default class TableOfContent { const contentTopOffset = this.getScrollPadding(); /** - * Treat section as active if it reaches the 1/5 of viewport from top - * For example, for a window with 1006px height it will be 219px + * Additional offset for correct calculation of active section + * + * Cause opening page with anchor could scroll almost + * near to the target section and we need to add 1px to calculations */ - const activationOffset = window.innerHeight / 5; + const activationOffset = 1; const detectSection = () => { /** diff --git a/src/frontend/styles/components/header.pcss b/src/frontend/styles/components/header.pcss index 53c3a5a..9d31b09 100644 --- a/src/frontend/styles/components/header.pcss +++ b/src/frontend/styles/components/header.pcss @@ -1,5 +1,5 @@ html { - scroll-padding-top: calc(var(--layout-height-header) + 5vh); + scroll-padding-top: calc(var(--layout-height-header) + 10vh); } .docs-header {