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

Function updateHeightsInViewport

static/mergely/lib/codemirror.js:797–820  ·  view source on GitHub ↗
(cm)

Source from the content-addressed store, hash-verified

795 // Read the actual heights of the rendered lines, and update their
796 // stored heights to match.
797 function updateHeightsInViewport(cm) {
798 var display = cm.display;
799 var prevBottom = display.lineDiv.offsetTop;
800 for (var i = 0; i < display.view.length; i++) {
801 var cur = display.view[i], height;
802 if (cur.hidden) continue;
803 if (ie && ie_version < 8) {
804 var bot = cur.node.offsetTop + cur.node.offsetHeight;
805 height = bot - prevBottom;
806 prevBottom = bot;
807 } else {
808 var box = cur.node.getBoundingClientRect();
809 height = box.bottom - box.top;
810 }
811 var diff = cur.line.height - height;
812 if (height < 2) height = textHeight(display);
813 if (diff > .001 || diff < -.001) {
814 updateLineHeight(cur.line, height);
815 updateWidgetHeight(cur.line);
816 if (cur.rest) for (var j = 0; j < cur.rest.length; j++)
817 updateWidgetHeight(cur.rest[j]);
818 }
819 }
820 }
821
822 // Read and store the height of line widgets associated with the
823 // given line.

Callers 4

updateScrollbarsFunction · 0.70
postUpdateDisplayFunction · 0.70
updateDisplaySimpleFunction · 0.70
endOperation_R2Function · 0.70

Calls 3

textHeightFunction · 0.70
updateLineHeightFunction · 0.70
updateWidgetHeightFunction · 0.70

Tested by

no test coverage detected