MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / updateScrollbars

Function updateScrollbars

static/js/codemirror/codemirror.js:320–345  ·  view source on GitHub ↗
(d /* display */, docHeight)

Source from the content-addressed store, hash-verified

318 // Re-synchronize the fake scrollbars with the actual size of the
319 // content. Optionally force a scrollTop.
320 function updateScrollbars(d /* display */, docHeight) {
321 var totalHeight = docHeight + 2 * paddingTop(d);
322 d.sizer.style.minHeight = d.heightForcer.style.top = totalHeight + "px";
323 var scrollHeight = Math.max(totalHeight, d.scroller.scrollHeight);
324 var needsH = d.scroller.scrollWidth > d.scroller.clientWidth;
325 var needsV = scrollHeight > d.scroller.clientHeight;
326 if (needsV) {
327 d.scrollbarV.style.display = "block";
328 d.scrollbarV.style.bottom = needsH ? scrollbarWidth(d.measure) + "px" : "0";
329 d.scrollbarV.firstChild.style.height =
330 (scrollHeight - d.scroller.clientHeight + d.scrollbarV.clientHeight) + "px";
331 } else d.scrollbarV.style.display = "";
332 if (needsH) {
333 d.scrollbarH.style.display = "block";
334 d.scrollbarH.style.right = needsV ? scrollbarWidth(d.measure) + "px" : "0";
335 d.scrollbarH.firstChild.style.width =
336 (d.scroller.scrollWidth - d.scroller.clientWidth + d.scrollbarH.clientWidth) + "px";
337 } else d.scrollbarH.style.display = "";
338 if (needsH && needsV) {
339 d.scrollbarFiller.style.display = "block";
340 d.scrollbarFiller.style.height = d.scrollbarFiller.style.width = scrollbarWidth(d.measure) + "px";
341 } else d.scrollbarFiller.style.display = "";
342
343 if (mac_geLion && scrollbarWidth(d.measure) === 0)
344 d.scrollbarV.style.minWidth = d.scrollbarH.style.minHeight = mac_geMountainLion ? "18px" : "12px";
345 }
346
347 function visibleLines(display, doc, viewPort) {
348 var top = display.scroller.scrollTop, height = display.wrapper.clientHeight;

Callers 2

wrappingChangedFunction · 0.85
updateDisplayFunction · 0.85

Calls 2

paddingTopFunction · 0.85
scrollbarWidthFunction · 0.85

Tested by

no test coverage detected