From 71ec9f2c5f0e99a8622f81e09bfd4111238b99f2 Mon Sep 17 00:00:00 2001 From: tdro Date: Sat, 24 Feb 2024 18:33:47 -0500 Subject: static/js/pager: Fix and simplify :target offset --- static/js/pager.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'static') diff --git a/static/js/pager.ts b/static/js/pager.ts index e818d17..3f7279c 100644 --- a/static/js/pager.ts +++ b/static/js/pager.ts @@ -17,7 +17,7 @@ const link = function () { url = self.location.href.split("#")[0].split("?")[0]; }; - const scrollHash = function (url, load = false) { + const scrollHash = function (url) { const hash = self.location.hash; const fragment = hash.slice(1) && document.getElementById(hash.slice(1)); const fragmented = hash.length > 0; @@ -25,7 +25,9 @@ if (hashed) { self.location.hash = hash; self.location.href = hash; - if (load) fragment.scrollIntoView(); + if ("scroll-margin-top" in document.body.style === false && fragment.textContent !== "") { + self.scrollBy(0, -6 * parseFloat(getComputedStyle(document.documentElement).fontSize)); + } } return hashed; }; -- cgit v1.2.3