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

Function alignHorizontally

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

Source from the content-addressed store, hash-verified

4777 // Re-align line numbers and gutter marks to compensate for
4778 // horizontal scrolling.
4779 function alignHorizontally(cm) {
4780 var display = cm.display,
4781 view = display.view
4782 if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) {
4783 return
4784 }
4785 var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft
4786 var gutterW = display.gutters.offsetWidth,
4787 left = comp + "px"
4788 for (var i = 0; i < view.length; i++) {
4789 if (!view[i].hidden) {
4790 if (cm.options.fixedGutter) {
4791 if (view[i].gutter) {
4792 view[i].gutter.style.left = left
4793 }
4794 if (view[i].gutterBackground) {
4795 view[i].gutterBackground.style.left = left
4796 }
4797 }
4798 var align = view[i].alignable
4799 if (align) {
4800 for (var j = 0; j < align.length; j++) {
4801 align[j].style.left = left
4802 }
4803 }
4804 }
4805 }
4806 if (cm.options.fixedGutter) {
4807 display.gutters.style.left = comp + gutterW + "px"
4808 }
4809 }
4810
4811 // Used to ensure that the line number gutter is still the right
4812 // size for the current document size. Returns true when an update

Callers 2

setScrollLeftFunction · 0.85
guttersChangedFunction · 0.85

Calls 1

compensateForHScrollFunction · 0.85

Tested by

no test coverage detected