MCPcopy
hub / github.com/witheve/Eve / estimateHeight

Function estimateHeight

src/codemirror.js:273–289  ·  view source on GitHub ↗
(cm)

Source from the content-addressed store, hash-verified

271 // first approximation until the line becomes visible (and is thus
272 // properly measurable).
273 function estimateHeight(cm) {
274 var th = textHeight(cm.display), wrapping = cm.options.lineWrapping;
275 var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3);
276 return function(line) {
277 if (lineIsHidden(cm.doc, line)) return 0;
278
279 var widgetsHeight = 0;
280 if (line.widgets) for (var i = 0; i < line.widgets.length; i++) {
281 if (line.widgets[i].height) widgetsHeight += line.widgets[i].height;
282 }
283
284 if (wrapping)
285 return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th;
286 else
287 return widgetsHeight + th;
288 };
289 }
290
291 function estimateLineHeights(cm) {
292 var doc = cm.doc, est = estimateHeight(cm);

Callers 4

estimateLineHeightsFunction · 0.85
codemirror.jsFile · 0.85
updateLineFunction · 0.85

Calls 3

textHeightFunction · 0.85
charWidthFunction · 0.85
lineIsHiddenFunction · 0.85

Tested by

no test coverage detected