Skip to content

Instantly share code, notes, and snippets.

@r38y
Last active December 15, 2015 13:29
Show Gist options
  • Save r38y/5268092 to your computer and use it in GitHub Desktop.
Save r38y/5268092 to your computer and use it in GitHub Desktop.
Fixes the bouncing viewport when scrolling in full-window javascript apps. You mostly see this in Chrome (?).
# Uses https://github.com/brandonaaron/jquery-mousewheel
fixScrolling: (elem) ->
$('body').on 'mousewheel', elem, (e, d) ->
$elem = $(elem)
height = $elem.height()
scrollHeight = $elem.get(0).scrollHeight
if (d < 0 && (this.scrollTop is (scrollHeight - height)) || (d > 0 && this.scrollTop is 0))
e.preventDefault()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment