aboutsummaryrefslogtreecommitdiff
path: root/assets/js
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 /assets/js
parent070ca2eb3c21fe098da1f0d059bc3e6f0b64b16c (diff)
downloadcanory-71ec9f2c5f0e99a8622f81e09bfd4111238b99f2.tar.gz
canory-71ec9f2c5f0e99a8622f81e09bfd4111238b99f2.tar.bz2
canory-71ec9f2c5f0e99a8622f81e09bfd4111238b99f2.zip
static/js/pager: Fix and simplify :target offset
Diffstat (limited to 'assets/js')
-rw-r--r--assets/js/index.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/assets/js/index.js b/assets/js/index.js
index a6c5f47..69001ad 100644
--- a/assets/js/index.js
+++ b/assets/js/index.js
@@ -13,7 +13,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;
@@ -21,7 +21,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;
};