diff --git a/lib/codemirror.js b/lib/codemirror.js index a7e4f519048e4b01ff8636ee1a0959ad6f60c1c2..dd86e2b4fe9eef577906044622a8fe57227921b4 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -418,13 +418,15 @@ var CodeMirror = (function() { connect(div, "paste", function(){input.focus(); fastPoll();}); connect(input, "paste", fastPoll); - function stopScroll(e) { - var up = e.e.detail ? e.e.detail < 0 : e.e.wheelDelta > 0; - if (up ? div.scrollTop == 0 : div.scrollTop + div.clientHeight >= div.scrollHeight) - e.stop(); + if (options.blockDocumentScroll) { + function stopScroll(e) { + var up = e.e.detail ? e.e.detail < 0 : e.e.wheelDelta > 0; + if (up ? div.scrollTop == 0 : div.scrollTop + div.clientHeight >= div.scrollHeight) + e.stop(); + } + connect(div, "mousewheel", stopScroll); + connect(div, "DOMMouseScroll", stopScroll); } - connect(div, "mousewheel", stopScroll); - connect(div, "DOMMouseScroll", stopScroll); if (document.activeElement == input) onFocus(); else onBlur(); @@ -1526,6 +1528,7 @@ var CodeMirror = (function() { enterMode: "indent", electricChars: true, keyHook: null, + blockDocumentScroll: true, lineNumbers: false, gutter: false, firstLineNumber: 1, diff --git a/manual.html b/manual.html index 74f5242460873015f7542000abfa74a2f5ce25f2..eea79a43cd687bd24ba893cffba56c16e7909c9e 100644 --- a/manual.html +++ b/manual.html @@ -173,6 +173,11 @@ indentation (only works if the mode supports indentation). Default is true.</dd> + <dt id="option_blockDocumentScroll"><code>blockDocumentScroll (boolean)</code></dt> + <dd>When true (the default) using the scroll wheel inside the + editor will only cause the editor to scroll, not the document + around it.</dd> + <dt id="option_lineNumbers"><code>lineNumbers (boolean)</code></dt> <dd>Whether to show line numbers to the left of the editor.</dd>