MCPcopy
hub / github.com/DHTMLX/gantt / estimateHeight

Function estimateHeight

samples/common/codehighlight/codemirror.js:2926–2942  ·  view source on GitHub ↗
(cm)

Source from the content-addressed store, hash-verified

2924 // first approximation until the line becomes visible (and is thus
2925 // properly measurable).
2926 function estimateHeight(cm) {
2927 var th = textHeight(cm.display), wrapping = cm.options.lineWrapping;
2928 var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3);
2929 return function (line) {
2930 if (lineIsHidden(cm.doc, line)) { return 0 }
2931
2932 var widgetsHeight = 0;
2933 if (line.widgets) { for (var i = 0; i < line.widgets.length; i++) {
2934 if (line.widgets[i].height) { widgetsHeight += line.widgets[i].height; }
2935 } }
2936
2937 if (wrapping)
2938 { return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th }
2939 else
2940 { return widgetsHeight + th }
2941 }
2942 }
2943
2944 function estimateLineHeights(cm) {
2945 var doc = cm.doc, est = estimateHeight(cm);

Callers 4

LineFunction · 0.85
updateLineFunction · 0.85
estimateLineHeightsFunction · 0.85

Calls 3

textHeightFunction · 0.85
charWidthFunction · 0.85
lineIsHiddenFunction · 0.85

Tested by

no test coverage detected