aboutsummaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2024-02-24 18:33:47 -0500
committertdro <tdro@noreply.example.com>2024-02-24 18:33:47 -0500
commit71ec9f2c5f0e99a8622f81e09bfd4111238b99f2 (patch)
tree24597de4d7c8702bc10f3a2c82ddc00b1efec7d7 /static
parent070ca2eb3c21fe098da1f0d059bc3e6f0b64b16c (diff)
downloadcanory-71ec9f2c5f0e99a8622f81e09bfd4111238b99f2.tar.gz
canory-71ec9f2c5f0e99a8622f81e09bfd4111238b99f2.tar.bz2
canory-71ec9f2c5f0e99a8622f81e09bfd4111238b99f2.zip
static/js/pager: Fix and simplify :target offset
Diffstat (limited to 'static')
-rw-r--r--static/js/pager.ts6
1 files changed, 4 insertions, 2 deletions
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;
};