MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / findPosV

Function findPosV

static/js/codemirror/codemirror.js:2557–2572  ·  view source on GitHub ↗
(cm, pos, dir, unit)

Source from the content-addressed store, hash-verified

2555 }
2556
2557 function findPosV(cm, pos, dir, unit) {
2558 var doc = cm.doc, x = pos.left, y;
2559 if (unit == "page") {
2560 var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight);
2561 y = pos.top + dir * pageSize;
2562 } else if (unit == "line") {
2563 y = dir > 0 ? pos.bottom + 3 : pos.top - 3;
2564 }
2565 for (;;) {
2566 var target = coordsChar(cm, x, y);
2567 if (!target.outside) break;
2568 if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = true; break; }
2569 y += dir * 5;
2570 }
2571 return target;
2572 }
2573
2574 function findWordAt(line, pos) {
2575 var start = pos.ch, end = pos.ch;

Callers 1

codemirror.jsFile · 0.85

Calls 1

coordsCharFunction · 0.85

Tested by

no test coverage detected