-
Notifications
You must be signed in to change notification settings - Fork 0
/
everything.js
102 lines (81 loc) · 3.28 KB
/
everything.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
initEverything()
function initEverything() {
hljs.highlightAll();
let burgerMenu = document.querySelector('.burger-menu')
burgerMenu.addEventListener('click', toggleDropdown)
let dropdownMenu = document.querySelector('.dropdown')
function toggleDropdown() {
if (dropdownMenu.classList.contains('visible')) {
dropdownMenu.classList = "dropdown"
} else {
dropdownMenu.classList = "dropdown visible"
}
}
let headController = new ScrollMagic.Controller()
let headScene = new ScrollMagic.Scene({
triggerElement: ".filler",
triggerHook: 0.9,
})
.setTween([".head-image", ".main-nav", ".head-message"], 1, {scale: 10, display: 'none'}) // trigger a TweenMax.to tween
// .addIndicators({name: "filler div"})
.addTo(headController)
let projectsController = new ScrollMagic.Controller()
let whiteScene = new ScrollMagic.Scene({
triggerElement: ".trigger",
triggerHook: 0
})
.setTween(".home-div", 1, {
backgroundImage: "radial-gradient(white 15%, black 80%)"
})
// .addIndicators({name: "trigger div"})
.addTo(projectsController)
let projectElements = document.getElementsByClassName("project-link");
for (let i = 0; i < projectElements.length; i++) {
let target = projectElements[i]
let projectTl = new TimelineMax()
projectTl.from(target, 0.25, {visibility: 'hidden'})
projectTl.to(target, 0.25, {visibility: 'visible', delay: 1 + (0.5 * i)})
new ScrollMagic.Scene({
triggerElement: ".trigger",
triggerHook: 0,
})
.setTween(projectTl) // add class toggle
// .addIndicators({name: "projects-div" })
.addTo(projectsController);
}
let mainController = new ScrollMagic.Controller()
let mainScene = new ScrollMagic.Scene({
triggerElement: ".home-div",
triggerHook: 0
})
.setPin(".home-div")
.addTo(mainController);
// ============================= PROJECT PAGE =============================
let projectPageController = new ScrollMagic.Controller({
globalSceneOptions: {
triggerHook: 'onLeave',
duration: 0,
}
});
let slides = document.querySelectorAll(".wipe,.overview");
for (let i = 0; i < slides.length; i++) {
new ScrollMagic.Scene({
triggerElement: slides[i],
offset: -60
})
.setPin(slides[i], {pushFollowers: false})
// .addIndicators()
.addTo(projectPageController);
}
let parallaxController = new ScrollMagic.Controller({globalSceneOptions: {triggerHook: "onEnter", duration: "200%"}});
// build scenes
let parallaxSections = document.querySelectorAll(".parallaxParent")
let parallaxSectionsDiv = document.querySelectorAll(".parallaxParent > div")
for (let i = 0; i < parallaxSections.length; i++ ) {
new ScrollMagic.Scene({
triggerElement: parallaxSections[i]
})
.setTween(parallaxSectionsDiv[i], {y: "80%", ease: Linear.easeNone})
.addTo(parallaxController);
}
} // init EVERYTHING