parallax.coffee
579 Bytes
#
# OK, this is not really a parallax... I just want to see my content move
# somewhat faster than the background... hey, ho, let's go
#
window.App ||= {}
content_top = content_left = width_delta = height_delta = 0
App.init = ->
App.scroll = ->
v_scroll = $(document).scrollTop()
section = Math.floor(v_scroll / $(window).innerHeight())
$($(".section")[section]).css(
"background-position", "center -" +
(v_scroll-(section*$(window).innerHeight()))/2 + "px")
$(document).on "page:change", ->
App.init()
$(window).on "scroll", ->
App.scroll()
# vim: set ts=2 sw=2: