Release v0.4.0: dev -> main #251
@@ -54,7 +54,16 @@
|
|||||||
// is closest to its line's top.
|
// is closest to its line's top.
|
||||||
var bodyTop = body.getBoundingClientRect().top;
|
var bodyTop = body.getBoundingClientRect().top;
|
||||||
var lh = parseFloat(getComputedStyle(body).lineHeight) || 1;
|
var lh = parseFloat(getComputedStyle(body).lineHeight) || 1;
|
||||||
var totalRows = Math.max(lines.length, Math.ceil(body.getBoundingClientRect().height / lh));
|
var maxBottom = 0;
|
||||||
|
for (var j = 0; j < lines.length; j++) {
|
||||||
|
var btm = lines[j].getBoundingClientRect().bottom - bodyTop;
|
||||||
|
if (btm > maxBottom) maxBottom = btm;
|
||||||
|
}
|
||||||
|
// Rows needed through the last visual row of the deepest line (ceil, so a
|
||||||
|
// partially-filled last row still gets its gutter span).
|
||||||
|
// Rows needed: floor(last line bottom / lh) + 1 — the row a line STARTS on
|
||||||
|
// must exist even when its bottom lands exactly on the body's edge.
|
||||||
|
var totalRows = Math.max(lines.length, Math.floor(maxBottom / lh) + 1);
|
||||||
gutter.textContent = '';
|
gutter.textContent = '';
|
||||||
var frag = document.createDocumentFragment();
|
var frag = document.createDocumentFragment();
|
||||||
var spans = [];
|
var spans = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user