Skip to content

Commit 7cd9058

Browse files
committed
Little fix for page title after last commit
1 parent cada132 commit 7cd9058

File tree

1 file changed

+21
-23
lines changed

1 file changed

+21
-23
lines changed

web/src/overrides/PageTitle.astro

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -116,35 +116,33 @@ import { functionTypePrettyName } from "@src/utils/functions";
116116
</style>
117117

118118
<script>
119-
document.addEventListener("DOMContentLoaded", () => {
120-
const title = document.querySelector(".page-title");
121-
const sizeClasses = ["size-h2", "size-h3", "size-h4"];
119+
document.addEventListener("DOMContentLoaded", () => {
120+
const title = document.querySelector(".page-title");
121+
const sizeClasses = ["size-h2", "size-h3", "size-h4"];
122122

123-
function adjustTitle() {
124-
if (!title) return;
123+
function adjustTitle() {
124+
if (!title) return;
125125

126-
title.classList.remove(...sizeClasses);
126+
title.classList.remove(...sizeClasses);
127127

128-
requestAnimationFrame(() => {
129-
const lineHeight = parseFloat(
130-
getComputedStyle(title).lineHeight,
131-
);
128+
requestAnimationFrame(() => {
129+
const lineHeight = parseFloat(getComputedStyle(title).lineHeight);
130+
let lines = Math.round(title.scrollHeight / lineHeight);
132131

133-
for (const sizeClass of sizeClasses) {
134-
title.classList.remove(...sizeClasses);
135-
if (sizeClass) title.classList.add(sizeClass);
132+
if (lines <= 1) return;
136133

137-
const lines = Math.round(title.scrollHeight / lineHeight);
138-
console.log(lines);
134+
for (const sizeClass of sizeClasses) {
135+
title.classList.remove(...sizeClasses);
136+
title.classList.add(sizeClass);
139137

140-
if (lines <= 1) {
141-
break;
142-
}
143-
}
144-
});
145-
}
138+
lines = Math.round(title.scrollHeight / lineHeight);
146139

147-
adjustTitle();
148-
window.addEventListener("resize", adjustTitle);
140+
if (lines <= 1) break;
141+
}
149142
});
143+
}
144+
145+
adjustTitle();
146+
window.addEventListener("resize", adjustTitle);
147+
});
150148
</script>

0 commit comments

Comments
 (0)