Skip to content

Instantly share code, notes, and snippets.

@ryanflorence
Forked from zwily/downscroller.coffee
Last active December 13, 2015 17:28
Show Gist options
  • Save ryanflorence/4947457 to your computer and use it in GitHub Desktop.
Save ryanflorence/4947457 to your computer and use it in GitHub Desktop.
## Puts a big annoying arrow in your window when you're not scrolled down, like a dummy
#
scrollAlert = $("<div style='position: fixed; z-index: 10000; bottom: -10px; left: 10px; font-size: 10em; opacity: 0.5'>⬇</div>")
count = $("<div style='position: fixed; z-index: 10000; bottom: -50px; left: 50px; color: #fff'></div>")
lineCount = 0
showing = false
body = $ document.body
win = $ window
doc = $ document
show = ->
return if showing
scrollAlert.appendTo(body).fadeIn()
count.html(lineCount).appendTo(body).fadeIn()
showing = true
remove = ->
return unless showing
scrollAlert.fadeOut -> scrollAlert.remove()
count.fadeOut -> count.remove()
lineCount = 0
showing = false
checkBottom = ->
atBottom = win.scrollTop() + win.height() >= doc.height()
if atBottom then hide() else show()
onNewLine = ->
lineCount++
checkBottom()
$(window).scroll checkbottom
bind 'line', onNewLine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment