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

Function initScrollbars

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

Source from the content-addressed store, hash-verified

5262 var scrollbarModel = { native: NativeScrollbars, null: NullScrollbars }
5263
5264 function initScrollbars(cm) {
5265 if (cm.display.scrollbars) {
5266 cm.display.scrollbars.clear()
5267 if (cm.display.scrollbars.addClass) {
5268 rmClass(cm.display.wrapper, cm.display.scrollbars.addClass)
5269 }
5270 }
5271
5272 cm.display.scrollbars = new scrollbarModel[cm.options.scrollbarStyle](
5273 function (node) {
5274 cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller)
5275 // Prevent clicks in the scrollbars from killing focus
5276 on(node, "mousedown", function () {
5277 if (cm.state.focused) {
5278 setTimeout(function () {
5279 return cm.display.input.focus()
5280 }, 0)
5281 }
5282 })
5283 node.setAttribute("cm-not-content", "true")
5284 },
5285 function (pos, axis) {
5286 if (axis == "horizontal") {
5287 setScrollLeft(cm, pos)
5288 } else {
5289 updateScrollTop(cm, pos)
5290 }
5291 },
5292 cm
5293 )
5294 if (cm.display.scrollbars.addClass) {
5295 addClass(cm.display.wrapper, cm.display.scrollbars.addClass)
5296 }
5297 }
5298
5299 // Operations are used to wrap a series of changes to the editor
5300 // state in such a way that each change won't have to update the

Callers 2

defineOptionsFunction · 0.85
CodeMirrorFunction · 0.85

Calls 5

rmClassFunction · 0.85
setScrollLeftFunction · 0.85
updateScrollTopFunction · 0.85
addClassFunction · 0.85
onFunction · 0.70

Tested by

no test coverage detected