You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
870 B
38 lines
870 B
#
|
|
# 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 ||= {}
|
|
|
|
App.init = ->
|
|
this.$slides = $('.section')
|
|
this.$menu = $("#nav a")
|
|
this.section = 0
|
|
this.$menu.each ->
|
|
$target = $(this.hash)
|
|
if $target.length
|
|
$(this).click ->
|
|
$('html, body').animate({scrollTop: $target.offset().top+1}, 1000)
|
|
return false
|
|
|
|
App.scroll = ->
|
|
if not this.$slides
|
|
return 0
|
|
v_scroll = $(document).scrollTop()
|
|
for slide,i in this.$slides
|
|
if v_scroll >= slide.offsetTop
|
|
this.section = i
|
|
if not $(this.$menu[this.section]).hasClass('active')
|
|
$(this.$menu).removeClass('active')
|
|
$(this.$menu[this.section]).addClass('active')
|
|
|
|
$(document).on "page:change", ->
|
|
App.init()
|
|
|
|
$(window).on "scroll", ->
|
|
App.scroll()
|
|
|
|
$(document).ready ->
|
|
App.init()
|
|
|
|
# vim: set ts=2 sw=2:
|