From 3c3a646d423caad334b2086e76d2ccdf34f6d4f7 Mon Sep 17 00:00:00 2001 From: Michael Irwin Date: Tue, 14 Mar 2017 17:02:53 -0400 Subject: [PATCH 1/2] Fixed characterHeight calculation, which could cause overflowing The previous calculation was simply using the height of the letter W, but wasn't taking into account that each row has a lineHeight, which might be greater. If the lineHeight is .4px off, after many rows, it will cause the proposedGeometry to have an extra row, potentially causing hidden rows (based on layout). --- src/addons/fit/fit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/addons/fit/fit.js b/src/addons/fit/fit.js index 11fc6eb7..390cc0e9 100644 --- a/src/addons/fit/fit.js +++ b/src/addons/fit/fit.js @@ -56,7 +56,7 @@ subjectRow.innerHTML = 'W'; // Common character for measuring width, although on monospace characterWidth = subjectRow.getBoundingClientRect().width; subjectRow.style.display = ''; // Revert style before calculating height, since they differ. - characterHeight = parseInt(subjectRow.offsetHeight); + characterHeight = parseFloat(term.rowContainer.style.lineHeight); subjectRow.innerHTML = contentBuffer; rows = parseInt(availableHeight / characterHeight); From 0cb8ecc6f72638aa65f6c04fc5fd5a241f2f482c Mon Sep 17 00:00:00 2001 From: Michael Irwin Date: Wed, 15 Mar 2017 08:28:44 -0400 Subject: [PATCH 2/2] Use boundingClientRect instead of style to get actual height PR #598 --- src/addons/fit/fit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/addons/fit/fit.js b/src/addons/fit/fit.js index 390cc0e9..46b79e9b 100644 --- a/src/addons/fit/fit.js +++ b/src/addons/fit/fit.js @@ -56,7 +56,7 @@ subjectRow.innerHTML = 'W'; // Common character for measuring width, although on monospace characterWidth = subjectRow.getBoundingClientRect().width; subjectRow.style.display = ''; // Revert style before calculating height, since they differ. - characterHeight = parseFloat(term.rowContainer.style.lineHeight); + characterHeight = subjectRow.getBoundingClientRect().height; subjectRow.innerHTML = contentBuffer; rows = parseInt(availableHeight / characterHeight);