From 207993ba46d8e771e8a2faf49a6d72e1437eba04 Mon Sep 17 00:00:00 2001 From: IZUMIRU Date: Tue, 28 Nov 2023 01:49:19 +0900 Subject: [PATCH 1/5] feat: Add toc scroll --- resources/js/functions.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/resources/js/functions.js b/resources/js/functions.js index 322652b95a..c28647c237 100644 --- a/resources/js/functions.js +++ b/resources/js/functions.js @@ -282,6 +282,10 @@ $(document).ready(function() { autoId: true, numerate: false }); + const target = $('#sidebar-toc .active'); + if (target.length) { + $('#sidebar-toc').scrollTop(target.offset().top); + }; } }); From e2d0fd425bb9b91cb9e69972415e67a952b6594c Mon Sep 17 00:00:00 2001 From: IZUMIRU Date: Tue, 28 Nov 2023 02:33:57 +0900 Subject: [PATCH 2/5] fix: Use animate() and position() --- _sass/layout/toc.scss | 1 + resources/js/functions.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/_sass/layout/toc.scss b/_sass/layout/toc.scss index e4e284bd64..73f54dc69f 100644 --- a/_sass/layout/toc.scss +++ b/_sass/layout/toc.scss @@ -28,6 +28,7 @@ .inner-toc { max-height: 60vh; overflow-y: auto; + position: relative; @include bp(large) { max-height: none; diff --git a/resources/js/functions.js b/resources/js/functions.js index c28647c237..747f70f5ef 100644 --- a/resources/js/functions.js +++ b/resources/js/functions.js @@ -284,7 +284,7 @@ $(document).ready(function() { }); const target = $('#sidebar-toc .active'); if (target.length) { - $('#sidebar-toc').scrollTop(target.offset().top); + $('#sidebar-toc').animate({scrollTop: target.position().top}, 200); }; } }); From 8d3ecf3bccb8f277b07a1920df20305145548553 Mon Sep 17 00:00:00 2001 From: IZUMIRU Date: Tue, 28 Nov 2023 22:18:49 +0900 Subject: [PATCH 3/5] fix: Adjust margin top --- resources/js/functions.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/resources/js/functions.js b/resources/js/functions.js index 747f70f5ef..4d7544020f 100644 --- a/resources/js/functions.js +++ b/resources/js/functions.js @@ -284,7 +284,8 @@ $(document).ready(function() { }); const target = $('#sidebar-toc .active'); if (target.length) { - $('#sidebar-toc').animate({scrollTop: target.position().top}, 200); + const marginTop = 10; + $('#sidebar-toc').animate({scrollTop: target.position().top - marginTop}, 200); }; } }); From 91c7fd700392af92bb78aa4407a20402ffc0d439 Mon Sep 17 00:00:00 2001 From: IZUMIRU Date: Tue, 28 Nov 2023 22:38:57 +0900 Subject: [PATCH 4/5] fix: Apply to book toc --- _includes/sidebar-toc-multipage-overview.html | 2 +- _sass/layout/toc.scss | 9 --------- resources/js/functions.js | 2 +- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/_includes/sidebar-toc-multipage-overview.html b/_includes/sidebar-toc-multipage-overview.html index cf614c8da0..4f9d7cb75c 100644 --- a/_includes/sidebar-toc-multipage-overview.html +++ b/_includes/sidebar-toc-multipage-overview.html @@ -1,6 +1,6 @@ {% assign pagetype = page.type %}
-