From 5642bc3c9816f8b8da2bd092874460c633317de4 Mon Sep 17 00:00:00 2001 From: YUCLing Date: Tue, 17 Dec 2024 20:05:03 +0800 Subject: [PATCH 1/2] fix: affixed sidebar offset backported https://github.com/flarum/framework/commit/11fc74db3f6e76dfcaa2fabdb3213e809e31ddb5 and https://github.com/flarum/framework/commit/ea21ef4c23ac8c7f9541b69905f1af3b69bc8619 --- .../js/src/forum/components/AffixedSidebar.js | 53 +++++++++++-------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/framework/core/js/src/forum/components/AffixedSidebar.js b/framework/core/js/src/forum/components/AffixedSidebar.js index 3cba6e88ef..b5a78cabbf 100644 --- a/framework/core/js/src/forum/components/AffixedSidebar.js +++ b/framework/core/js/src/forum/components/AffixedSidebar.js @@ -1,15 +1,23 @@ import Component from '../../common/Component'; /** - * The `AffixedSidebar` component uses Bootstrap's "affix" plugin to keep a + * Calculate the height of element with margin. + * @param {HTMLElement} element The element. + * @returns {number} The height of element with margin. + */ +function heightWithMargin(element) { + const style = getComputedStyle(element); + return element.getBoundingClientRect().height + parseInt(style.marginBottom, 10) + parseInt(style.marginTop, 10); +} + +/** + * The `AffixedSidebar` component uses sticky position to keep a * sidebar navigation at the top of the viewport when scrolling. * * ### Children * * The component must wrap an element that itself wraps an