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

Function estimateHeight

external/.scrollLibs.js:4349–4373  ·  view source on GitHub ↗
(cm)

Source from the content-addressed store, hash-verified

4347 // first approximation until the line becomes visible (and is thus
4348 // properly measurable).
4349 function estimateHeight(cm) {
4350 var th = textHeight(cm.display),
4351 wrapping = cm.options.lineWrapping
4352 var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3)
4353 return function (line) {
4354 if (lineIsHidden(cm.doc, line)) {
4355 return 0
4356 }
4357
4358 var widgetsHeight = 0
4359 if (line.widgets) {
4360 for (var i = 0; i < line.widgets.length; i++) {
4361 if (line.widgets[i].height) {
4362 widgetsHeight += line.widgets[i].height
4363 }
4364 }
4365 }
4366
4367 if (wrapping) {
4368 return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th
4369 } else {
4370 return widgetsHeight + th
4371 }
4372 }
4373 }
4374
4375 function estimateLineHeights(cm) {
4376 var doc = cm.doc,

Callers 4

LineFunction · 0.85
updateLineFunction · 0.85
estimateLineHeightsFunction · 0.85

Calls 4

textHeightFunction · 0.85
charWidthFunction · 0.85
lineIsHiddenFunction · 0.85
maxMethod · 0.80

Tested by

no test coverage detected