Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Keep the chosen Terminal theme in view when its row changes width

Țugui Dragoșe92dfb9bcc54
diff --git a/docs/main.js b/docs/main.js
index 040acd33..2c67f585 100644
--- a/docs/main.js
+++ b/docs/main.js
@@ -107,8 +107,14 @@ const centerTheme = (button, behavior) => {
const item = button.parentElement;
themeList.scrollTo({ left: item.offsetLeft - (themeList.clientWidth - item.offsetWidth) / 2, behavior });
};
-const pressed = document.querySelector('[data-theme][aria-pressed="true"]');
-if (pressed) addEventListener("load", () => centerTheme(pressed, "instant"), { once: true });
+// The theme shown is centered again whenever the row changes width, as when it is first laid out.
+let themeRowWidth;
+new ResizeObserver(([{ contentRect }]) => {
+ if (contentRect.width === themeRowWidth) return;
+ themeRowWidth = contentRect.width;
+ const shown = document.querySelector('[data-theme][aria-pressed="true"]');
+ if (shown) centerTheme(shown, "instant");
+}).observe(themeList);
themeButtons.forEach((button) => {
const warm = () => { new Image().src = themeURL(button); };