Skip to content

Instantly share code, notes, and snippets.

@startswithaj
Created February 24, 2014 05:30
Show Gist options
  • Save startswithaj/9182441 to your computer and use it in GitHub Desktop.
Save startswithaj/9182441 to your computer and use it in GitHub Desktop.
overscroll
#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