|
|
@ -4,61 +4,33 @@ |
|
|
# |
|
|
# |
|
|
window.App ||= {} |
|
|
window.App ||= {} |
|
|
|
|
|
|
|
|
content_top = content_left = width_delta = height_delta = 0 |
|
|
|
|
|
|
|
|
|
|
|
App.init = -> |
|
|
App.init = -> |
|
|
$('a[href*=\\#]').each -> |
|
|
|
|
|
lpath = location.pathname.replace(/^\//,'') |
|
|
|
|
|
tpath = this.pathname.replace(/^\//,'') |
|
|
|
|
|
if lpath == tpath and |
|
|
|
|
|
location.hostname == this.hostname and |
|
|
|
|
|
this.hash.replace(/#/,'') |
|
|
|
|
|
$targetId = $(this.hash) |
|
|
|
|
|
$targetAnchor = $('[name=' + this.hash.slice(1) + ']') |
|
|
|
|
|
$target = if $targetId.length |
|
|
|
|
|
$targetId |
|
|
|
|
|
else |
|
|
|
|
|
if $targetAnchor.length |
|
|
|
|
|
$targetAnchor |
|
|
|
|
|
else |
|
|
|
|
|
false |
|
|
|
|
|
|
|
|
|
|
|
if $target |
|
|
|
|
|
targetOffset = $target.offset().top |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.$slides = $('.section') |
|
|
|
|
|
this.$menu = $("#nav a") |
|
|
|
|
|
this.section = 0 |
|
|
|
|
|
this.$menu.each -> |
|
|
|
|
|
$target = $(this.hash) |
|
|
|
|
|
if $target.length |
|
|
$(this).click -> |
|
|
$(this).click -> |
|
|
$('html, body').animate({scrollTop: targetOffset}, 1000) |
|
|
|
|
|
|
|
|
$('html, body').animate({scrollTop: $target.offset().top}, 1000) |
|
|
return false |
|
|
return false |
|
|
|
|
|
|
|
|
App.scroll = -> |
|
|
App.scroll = -> |
|
|
|
|
|
if not this.$slides |
|
|
|
|
|
return 0 |
|
|
v_scroll = $(document).scrollTop() |
|
|
v_scroll = $(document).scrollTop() |
|
|
section = Math.floor(v_scroll / $(window).innerHeight()) |
|
|
|
|
|
[section, section+1].forEach (section) -> |
|
|
|
|
|
bg_pos = -((v_scroll-(section*$(window).innerHeight()))/2) |
|
|
|
|
|
section_element = $($(".section")[section]) |
|
|
|
|
|
if section_element and section_element.css("background-image") != "none" |
|
|
|
|
|
content = section_element.find(".content") |
|
|
|
|
|
content.css("display", "none") |
|
|
|
|
|
section_element.css( |
|
|
|
|
|
"background-position", |
|
|
|
|
|
"center " + bg_pos + "px") |
|
|
|
|
|
content.css("display", "block") |
|
|
|
|
|
|
|
|
|
|
|
App.scroll2 = -> |
|
|
|
|
|
v_scroll = $(document).scrollTop() |
|
|
|
|
|
section = 0 |
|
|
|
|
|
for value, index in $(".section") |
|
|
|
|
|
if v_scroll >= $(value).offset().top |
|
|
|
|
|
section = index |
|
|
|
|
|
if not $($("#nav a")[section]).hasClass('active') |
|
|
|
|
|
$("#nav a").removeClass("active") |
|
|
|
|
|
$($("#nav a")[section]).addClass('active') |
|
|
|
|
|
|
|
|
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", -> |
|
|
$(document).on "page:change", -> |
|
|
App.init() |
|
|
App.init() |
|
|
|
|
|
|
|
|
$(window).on "scroll", -> |
|
|
$(window).on "scroll", -> |
|
|
App.scroll2() |
|
|
|
|
|
|
|
|
App.scroll() |
|
|
|
|
|
|
|
|
$(document).ready -> |
|
|
$(document).ready -> |
|
|
App.init() |
|
|
App.init() |
|
|
|