MCPcopy Create free account
hub / github.com/breck7/scroll / estimateCoords

Function estimateCoords

external/.scrollLibs.js:4041–4050  ·  view source on GitHub ↗
(cm, pos)

Source from the content-addressed store, hash-verified

4039 // Used to cheaply estimate the coordinates for a position. Used for
4040 // intermediate scroll updates.
4041 function estimateCoords(cm, pos) {
4042 var left = 0
4043 pos = clipPos(cm.doc, pos)
4044 if (!cm.options.lineWrapping) {
4045 left = charWidth(cm.display) * pos.ch
4046 }
4047 var lineObj = getLine(cm.doc, pos.line)
4048 var top = heightAtLine(lineObj) + paddingTop(cm.display)
4049 return { left: left, right: left, top: top, bottom: top + lineObj.height }
4050 }
4051
4052 // Positions returned by coordsChar contain some extra information.
4053 // xRel is the relative x position of the input coordinates compared

Callers 1

resolveScrollToPosFunction · 0.85

Calls 5

clipPosFunction · 0.85
charWidthFunction · 0.85
getLineFunction · 0.85
heightAtLineFunction · 0.85
paddingTopFunction · 0.85

Tested by

no test coverage detected