MCPcopy Create free account
hub / github.com/TruthHun/BookStack / lineAtHeight

Function lineAtHeight

static/mergely/lib/codemirror.js:7817–7834  ·  view source on GitHub ↗
(chunk, h)

Source from the content-addressed store, hash-verified

7815 // Find the line at the given vertical position, using the height
7816 // information in the document tree.
7817 function lineAtHeight(chunk, h) {
7818 var n = chunk.first;
7819 outer: do {
7820 for (var i = 0; i < chunk.children.length; ++i) {
7821 var child = chunk.children[i], ch = child.height;
7822 if (h < ch) { chunk = child; continue outer; }
7823 h -= ch;
7824 n += child.chunkSize();
7825 }
7826 return n;
7827 } while (!chunk.lines);
7828 for (var i = 0; i < chunk.lines.length; ++i) {
7829 var line = chunk.lines[i], lh = line.height;
7830 if (h < lh) break;
7831 h -= lh;
7832 }
7833 return n + i;
7834 }
7835
7836
7837 // Find the height above the given line.

Callers 4

visibleLinesFunction · 0.70
coordsCharFunction · 0.70
gutterEventFunction · 0.70
codemirror.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected