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

Function estimateCoords

static/editor.md/lib/codemirror/lib/codemirror.js:2755–2761  ·  view source on GitHub ↗
(cm, pos)

Source from the content-addressed store, hash-verified

2753 // Used to cheaply estimate the coordinates for a position. Used for
2754 // intermediate scroll updates.
2755 function estimateCoords(cm, pos) {
2756 var left = 0, pos = clipPos(cm.doc, pos);
2757 if (!cm.options.lineWrapping) left = charWidth(cm.display) * pos.ch;
2758 var lineObj = getLine(cm.doc, pos.line);
2759 var top = heightAtLine(lineObj) + paddingTop(cm.display);
2760 return {left: left, right: left, top: top, bottom: top + lineObj.height};
2761 }
2762
2763 // Positions returned by coordsChar contain some extra information.
2764 // xRel is the relative x position of the input coordinates compared

Callers 1

resolveScrollToPosFunction · 0.70

Calls 5

clipPosFunction · 0.70
charWidthFunction · 0.70
getLineFunction · 0.70
heightAtLineFunction · 0.70
paddingTopFunction · 0.70

Tested by

no test coverage detected