From 368dc1d8ee6bdfcc22ab20dc3c9742eec5b87463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BB=91?= <1395348685z@gmail.com> Date: Sun, 25 Jul 2021 12:39:42 +0800 Subject: [PATCH] Correct scroll offset (#322) * Remove heading padding --- source/css/_common/components/post/post-body.styl | 2 -- source/css/_common/outline/mobile.styl | 2 +- source/css/_common/scaffolding/base.styl | 2 +- source/js/utils.js | 4 ++-- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/source/css/_common/components/post/post-body.styl b/source/css/_common/components/post/post-body.styl index 4c8094e..1b62c74 100644 --- a/source/css/_common/components/post/post-body.styl +++ b/source/css/_common/components/post/post-body.styl @@ -15,8 +15,6 @@ } h1, h2, h3, h4, h5, h6 { - padding-top: 10px; - // Supported plugins: hexo-renderer-markdown-it hexo-renderer-marked .header-anchor, .headerlink { border-bottom-style: none; diff --git a/source/css/_common/outline/mobile.styl b/source/css/_common/outline/mobile.styl index 9750231..01979a8 100644 --- a/source/css/_common/outline/mobile.styl +++ b/source/css/_common/outline/mobile.styl @@ -27,7 +27,7 @@ .post-body { // For headers narrow width. h1, h2, h3, h4, h5, h6 { - margin: 10px 0 8px; + margin: 20px 0 8px; } // Rewrite paddings & margins inside tags. diff --git a/source/css/_common/scaffolding/base.styl b/source/css/_common/scaffolding/base.styl index 17e5d5c..e9a9f99 100644 --- a/source/css/_common/scaffolding/base.styl +++ b/source/css/_common/scaffolding/base.styl @@ -34,7 +34,7 @@ h1, h2, h3, h4, h5, h6 { font-family: $font-family-headings; font-weight: bold; line-height: 1.5; - margin: 20px 0 15px; + margin: 30px 0 15px; } for $headline in (1 .. 6) { diff --git a/source/js/utils.js b/source/js/utils.js index 53e8ec5..7567b76 100644 --- a/source/js/utils.js +++ b/source/js/utils.js @@ -181,7 +181,7 @@ NexT.utils = { } if (!Array.isArray(NexT.utils.sections)) return; let index = NexT.utils.sections.findIndex(element => { - return element && element.getBoundingClientRect().top > 0; + return element && element.getBoundingClientRect().top > 10; }); if (index === -1) { index = NexT.utils.sections.length - 1; @@ -275,7 +275,7 @@ NexT.utils = { targets : document.scrollingElement, duration : 500, easing : 'linear', - scrollTop: offset + 10, + scrollTop: offset, complete : () => { history.pushState(null, document.title, element.href); }