Skip to content

Commit

Permalink
Turn off the pseudo-scrollbar on OS X Lion
Browse files Browse the repository at this point in the history
This is a temporary kludge. I hope we'll be able to find a better
solution. (This should bring back the flicker issue on Lion.)

Issue #727
  • Loading branch information
marijnh committed Aug 16, 2012
1 parent dd6bbc6 commit c0ab870
Showing 1 changed file with 7 additions and 22 deletions.
29 changes: 7 additions & 22 deletions lib/codemirror.js
Expand Up @@ -52,16 +52,13 @@ var CodeMirror = (function() {
// Needed to handle Tab key in KHTML
if (khtml) inputDiv.style.height = "1px", inputDiv.style.position = "absolute";

// Check for OS X >= 10.7. If so, we need to force a width on the scrollbar, and
// make it overlap the content. (But we only do this if the scrollbar doesn't already
// have a natural width. If the mouse is plugged in or the user sets the system pref
// to always show scrollbars, the scrollbar shouldn't overlap.)
if (mac_geLion) {
scrollbar.className += (overlapScrollbars() ? " cm-sb-overlap" : " cm-sb-nonoverlap");
} else if (ie_lt8) {
// Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
scrollbar.className += " cm-sb-ie7";
}
// Check for OS X >= 10.7. This has transparent scrollbars, so the
// overlaying of one scrollbar with another won't work. This is a
// temporary hack to simply turn off the overlay scrollbar. See
// issue #727.
if (mac_geLion) scrollbar.style.display = "none";
// Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
else if (ie_lt8) scrollbar.style.minWidth = "18px";

// Check for problem with IE innerHTML not working when we have a
// P (or similar) parent node.
Expand Down Expand Up @@ -867,18 +864,6 @@ var CodeMirror = (function() {
mover.style.top = displayOffset * textHeight() + "px";
}

// On Mac OS X Lion and up, detect whether the mouse is plugged in by measuring
// the width of a div with a scrollbar in it. If the width is <= 1, then
// the mouse isn't plugged in and scrollbars should overlap the content.
function overlapScrollbars() {
var tmpSbInner = elt("div", null, "CodeMirror-scrollbar-inner", "height: 200px");
var tmpSb = elt("div", [tmpSbInner], "CodeMirror-scrollbar", "position: absolute; left: -9999px; height: 100px;");
document.body.appendChild(tmpSb);
var result = (tmpSb.offsetWidth <= 1);
document.body.removeChild(tmpSb);
return result;
}

function computeMaxLength() {
maxLine = getLine(0); maxLineChanged = true;
var maxLineLength = maxLine.text.length;
Expand Down

0 comments on commit c0ab870

Please sign in to comment.