Skip to content

Instantly share code, notes, and snippets.

@wei-lee
Created December 1, 2011 15:43
Show Gist options
  • Save wei-lee/1417684 to your computer and use it in GitHub Desktop.
Save wei-lee/1417684 to your computer and use it in GitHub Desktop.
iScroll scroll bars
var myScroll;
function loaded() {
//assign a class name for the scroll bars
myScroll = new iScroll('wrapper', { scrollbarClass: 'myScrollbar' });
doBind();
}
function doBind(){
$('.myScrollbarV').unbind().bind('click', function(e){
var offsetY = e.offsetY;
var fullHeight = $('#thelist').height();
var scrollY = offsetY/$(this).height() * fullHeight;
myScroll.scrollTo(0, -1*scrollY, 100);
})
}
function refreshScroll(){
myScroll().refresh();
//need to bind the function again after refresh
doBind();
}
document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
document.addEventListener('DOMContentLoaded', loaded, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment