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

Function findPosV

static/mergely/lib/codemirror.js:4868–4883  ·  view source on GitHub ↗
(cm, pos, dir, unit)

Source from the content-addressed store, hash-verified

4866 // "page" or "line". The resulting position will have a hitSide=true
4867 // property if it reached the end of the document.
4868 function findPosV(cm, pos, dir, unit) {
4869 var doc = cm.doc, x = pos.left, y;
4870 if (unit == "page") {
4871 var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight);
4872 y = pos.top + dir * (pageSize - (dir < 0 ? 1.5 : .5) * textHeight(cm.display));
4873 } else if (unit == "line") {
4874 y = dir > 0 ? pos.bottom + 3 : pos.top - 3;
4875 }
4876 for (;;) {
4877 var target = coordsChar(cm, x, y);
4878 if (!target.outside) break;
4879 if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = true; break; }
4880 y += dir * 5;
4881 }
4882 return target;
4883 }
4884
4885 // EDITOR METHODS
4886

Callers 1

codemirror.jsFile · 0.70

Calls 2

textHeightFunction · 0.70
coordsCharFunction · 0.70

Tested by

no test coverage detected