This repository has been archived by the owner on Jan 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtji.js
76 lines (65 loc) · 2.21 KB
/
tji.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
jQuery(document).ready(function($) {
//Define initial variables
var taglineHeight = document.querySelector(".tji-about-brief").offsetTop;
var storyStart = document.querySelector(".story-sections").offsetTop;
var panelClosed = $(".nav-panel").hasClass("closed");
var navPanel = $(".nav-panel");
//Setup scroll functions for homepage
$(window).scroll(function() {
var height = $(window).scrollTop();
//Toggle header
/*
if ( height > taglineHeight ) {
$("header").addClass("fixed");
$(".custom-logo-link img").css("opacity", "1");
$(".main-navigation li").css("float","left");
$(".main-navigation li").css("margin-top","35px");
} else {
$("header").removeClass("fixed");
$(".custom-logo-link img").css("opacity", "0");
$(".main-navigation li").css("float","none");
$(".main-navigation li").css("margin-top","0");
}
*/
//Display or show nav panel
if ( height > storyStart - 100) {
$(".story-wrapper").addClass("story-mode");
$(".nav-panel").addClass("story-mode");
$(".story-sections").addClass("story-mode");
} else {
$(".story-wrapper").removeClass("story-mode");
$(".nav-panel").removeClass("story-mode");
$(".story-sections").removeClass("story-mode");
$(".viz-link").removeClass("active");
$(".nav-link").removeClass("active");
}
});
//Nav panel toggle switch
$(".panel-toggle a").click(function(e) {
e.preventDefault();
panelClosed = $(".nav-panel").hasClass("closed");
if (panelClosed) {
navPanel.removeClass("closed");
$(".panel-toggle a").html("→");
$(".story-sections").removeClass("closed");
} else {
navPanel.addClass("closed");
$(".panel-toggle a").html("←");
$(".story-sections").addClass("closed");
}
});
//Highlight nav links when section is active
$(".story-section").mouseenter(function() {
var section = $(this).attr("id");
var link = $("[href=#" + section + "]").parent();
$(".viz-link").removeClass("active");
$("[href=#" + section + "]").addClass("active");
link.addClass("active");
});
$(".viz-link").click(function() {
$(".nav-link").removeClass("active");
$(".viz-link").removeClass("active");
$(this).addClass("active");
$(this).parent().addClass("active");
});
});