Created
February 24, 2014 05:30
-
-
Save startswithaj/9182441 to your computer and use it in GitHub Desktop.
overscroll
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
#uses document because document will be topmost level in bubbling | |
$(document).on "touchmove", (e) -> | |
e.preventDefault() | |
#uses body because jquery on events are called off of the element they are | |
#added to, so bubbling would not work if we used document instead. | |
$("body").on "touchstart", ".mobile-scrolling", (e) -> | |
if e.currentTarget.scrollTop is 0 | |
e.currentTarget.scrollTop = 1 | |
else e.currentTarget.scrollTop -= 1 if e.currentTarget.scrollHeight is e.currentTarget.scrollTop + e.currentTarget.offsetHeight | |
#prevents preventDefault from being called on document if it sees a scrollable div | |
$("body").on "touchmove", ".mobile-scrolling", (e) -> | |
e.stopPropagation() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment