I would like to detect when the user scrolls past a certain point in the window.
[Meta]
X
scroll below = alert()
I'm quite new to CoffeeScript, so any help would be great!
What I currently have is this:
$("#area_1").bind('scroll', ->
scrollPosition = $(this).scrollTop() + $(this).outerHeight()
divTotalHeight = $(this)[0].scrollHeight()
if (scrollPosition >= divTotalHeight)
alert('end reached')
)
And no alert is showing up. Any tips?
Update I suspect that my problem have to do with my two variables. Here is an example:
$("#area_1").bind($(window).scroll ->
alert('before 1') # Gets called
scrollPosition = $(this).scrollTop() + $(this).outerHeight()
divTotalHeight = $(this)[0].scrollHeight()
alert('before 2') # Never gets called
if (1 == 1)
alert('should get called but dosn't')
)