Skip to content

Instantly share code, notes, and snippets.

@Youka
Created December 12, 2017 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Youka/87ab61ac61c88c01e47977a28662990c to your computer and use it in GitHub Desktop.
Save Youka/87ab61ac61c88c01e47977a28662990c to your computer and use it in GitHub Desktop.
Move scrollbar from default bottom to top
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: '&#160;'
})
)
).css('overflow-x', 'hidden');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment