fix: images & resize TOC

This commit is contained in:
Pavel Korytov 2022-06-26 21:57:33 +03:00
parent e0886d64a5
commit 92ca9a8341
2 changed files with 23 additions and 4 deletions

View file

@ -55,7 +55,11 @@
file)) file))
file 'overwrite)) file 'overwrite))
;; (copy-directory (expand-file-name "~/dot-stats/img") "dot-stats/img" t t) (copy-directory
(expand-file-name
(format "%s/repos/dotfiles/dot-imgs/"
(vc-find-root default-directory ".git")))
"dot-imgs" t t)
(dolist (file my/config-files) (dolist (file my/config-files)
(with-temp-buffer (with-temp-buffer

View file

@ -5,7 +5,7 @@ let currentActiveLinkId = null;
let elemsToHide = []; let elemsToHide = [];
let linksById = {}; let linksById = {};
let headerObserver; let headerObserver = null;
function observeHeadings() { function observeHeadings() {
const links = document.querySelectorAll(`#${tocId} a`); const links = document.querySelectorAll(`#${tocId} a`);
@ -94,10 +94,25 @@ function showHeadings() {
} }
} }
function setUpObserver() {
if (document.documentElement.clientWidth >= (750 + 350 + 25)) {
if (headerObserver === null) {
observeHeadings();
observeButtons();
}
} else {
if (headerObserver !== null) {
headerObserver.disconnect();
headerObserver = null;
showHeadings();
}
}
}
window.addEventListener("load", (event) => { window.addEventListener("load", (event) => {
if ("IntersectionObserver" in window) { if ("IntersectionObserver" in window) {
observeHeadings(); setUpObserver();
observeButtons(); window.addEventListener("resize", setUpObserver);
} }
}); });