mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 16:34:31 +08:00
DEV: Small refactor to header offset (#15421)
Centralizes calculations in a helper under the site header component. This also reverts a small CSS change to the composer: since ac79c5ef, the composer height was not including the grippie, which means that the composer height was off by 11 pixels, and the topic progress widget was sometimes being displayed cut off by 11 pixels.
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import discourseDebounce from "discourse-common/lib/debounce";
|
||||
import { headerOffset } from "discourse/components/site-header";
|
||||
import isElementInViewport from "discourse/lib/is-element-in-viewport";
|
||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||
|
||||
@ -85,17 +86,10 @@ function initialize(api) {
|
||||
return;
|
||||
}
|
||||
|
||||
const headerOffset =
|
||||
parseInt(
|
||||
getComputedStyle(document.body).getPropertyValue(
|
||||
"--header-offset"
|
||||
),
|
||||
10
|
||||
) || 0;
|
||||
const viewportOffset = post.getBoundingClientRect();
|
||||
|
||||
window.scrollTo({
|
||||
top: window.scrollY + viewportOffset.top - headerOffset,
|
||||
top: window.scrollY + viewportOffset.top - headerOffset(),
|
||||
behavior: "smooth",
|
||||
});
|
||||
},
|
||||
|
Reference in New Issue
Block a user