1
0
Fork 0
forked from OpenNeo/impress

Fix the two-line case for show more/less

I made two mistakes here! One is that you need to round up subpixel
line heights, and the other is that `clientHeight` is what I want, I
shouldn't include the margin!
This commit is contained in:
Emi Matchu 2024-01-19 04:35:44 -08:00
parent 4c809a5f5f
commit 68578aa929

View file

@ -19,9 +19,9 @@ try {
const tradeSections = document.querySelectorAll("#trade-hangers p");
for (const section of tradeSections) {
const oneLine = parseFloat(getComputedStyle(section)['line-height']);
const maxHeight = oneLine * 2;
const maxHeight = Math.ceil(oneLine * 2);
if (section.offsetHeight > maxHeight) {
if (section.clientHeight > maxHeight) {
section.style.maxHeight = `${maxHeight}px`;
section.setAttribute("data-overflows", "");
}