Created
December 1, 2011 15:43
-
-
Save wei-lee/1417684 to your computer and use it in GitHub Desktop.
iScroll scroll bars
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
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