Skip to content

Commit 18fbcd2

Browse files
committed
Check for overlay scrollbars on all platforms
Make sure the code that fixes the scrollbar style only fires once. Issue #2451
1 parent bd69455 commit 18fbcd2

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

lib/codemirror.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
var presto = /Opera\//.test(navigator.userAgent);
3434
var safari = /Apple Computer/.test(navigator.vendor);
3535
var khtml = /KHTML\//.test(navigator.userAgent);
36-
var mac_geLion = /Mac OS X 1\d\D([7-9]|\d\d)\D/.test(navigator.userAgent);
3736
var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent);
3837
var phantom = /PhantomJS/.test(navigator.userAgent);
3938

@@ -437,14 +436,18 @@
437436
d.gutterFiller.style.width = d.gutters.offsetWidth + "px";
438437
} else d.gutterFiller.style.display = "";
439438

440-
if (mac_geLion && scrollbarWidth(d.measure) === 0) {
441-
d.scrollbarV.style.minWidth = d.scrollbarH.style.minHeight = mac_geMountainLion ? "18px" : "12px";
442-
var barMouseDown = function(e) {
443-
if (e_target(e) != d.scrollbarV && e_target(e) != d.scrollbarH)
444-
operation(cm, onMouseDown)(e);
445-
};
446-
on(d.scrollbarV, "mousedown", barMouseDown);
447-
on(d.scrollbarH, "mousedown", barMouseDown);
439+
if (!cm.state.checkedOverlayScrollbar && measure.clientHeight > 0) {
440+
if (scrollbarWidth(d.measure) === 0) {
441+
var w = mac && !mac_geMountainLion ? "12px" : "18px";
442+
d.scrollbarV.style.minWidth = d.scrollbarH.style.minHeight = w;
443+
var barMouseDown = function(e) {
444+
if (e_target(e) != d.scrollbarV && e_target(e) != d.scrollbarH)
445+
operation(cm, onMouseDown)(e);
446+
};
447+
on(d.scrollbarV, "mousedown", barMouseDown);
448+
on(d.scrollbarH, "mousedown", barMouseDown);
449+
}
450+
cm.state.checkedOverlayScrollbar = true;
448451
}
449452
}
450453

0 commit comments

Comments
 (0)