-
-
Save siriokun/45dee04b3626cdd53d35 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* -------------------------------------- */ | |
//iOS-like scrollbar | |
var $niceScrollContainers = $("[data-ios-scroll]"); | |
$niceScrollContainers.each(function () { | |
var $container = $(this), | |
scrollClass = $container.attr("data-ios-scroll"), | |
cursorWidth = "6px", | |
$contentsLastChild = $container.children("*:last-child"); | |
if ($contentsLastChild.length) { | |
var pos = $contentsLastChild.position(), | |
containerContentsHeight = pos.top + $contentsLastChild.height() + parseInt($container.css("padding-top")) + parseInt($container.css("padding-bottom")); | |
} else return; | |
if (containerContentsHeight > $container.height()) { | |
$container | |
.niceScroll({ | |
cursorborder: "0", | |
cursorwidth: cursorWidth, | |
cursorcolor: "#797979", | |
background: "#e6e6e6" | |
}) | |
.rail | |
.addClass("ios-scroll ios-scroll-rail " + scrollClass) | |
.css("width", cursorWidth) | |
$container | |
.niceScroll() | |
.cursor | |
.addClass("ios-scroll ios-scroll-cursor " + scrollClass); | |
} else { | |
//Too short for scrollbars | |
$container | |
.parent() | |
.removeClass("fade-top fade-bottom"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment