Created
December 12, 2017 10:38
-
-
Save Youka/87ab61ac61c88c01e47977a28662990c to your computer and use it in GitHub Desktop.
Move scrollbar from default bottom to top
This file contains 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
function createTopScrollbar(frame) { | |
// Target even scrollable? | |
var scrollWidth = frame.get(0).scrollWidth; | |
if(scrollWidth > frame.width()) | |
// Add new top scrollbar and hide default (/bottom) scrollbar | |
frame.before( | |
jQuery('<div />', { | |
css: {'overflow-x': 'scroll'}, | |
height: getScrollbarSize() | |
}) | |
.on('scroll', function(event){frame.scrollLeft(event.target.scrollLeft);}) | |
.append( | |
jQuery('<div />', { | |
width: scrollWidth, | |
html: ' ' | |
}) | |
) | |
).css('overflow-x', 'hidden'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment