-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
80 lines (66 loc) · 1.55 KB
/
app.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
//common
function clickSwitchClass(target, className) {
$(target).on('click', function () {
$(target).not(this).removeClass(className);
$(this).addClass(className);
});
}
clickSwitchClass.all = () =>{
clickSwitchClass($('.menu-option a'), 'active')
clickSwitchClass($('.answer li'), 'active')
}
function clickToggleClass(target, className) {
$(target).on('click', function () {
$(this).toggleClass(className);
});
}
clickToggleClass.all = () =>{
clickToggleClass($('.nav-right'), 'active')
}
//loading
const loading = {}
loading.transition = () => {
const loading = $('.loading')
loading[0].onanimationend = (loading) => {
const timelineMenu = gsap.timeline()
timelineMenu.to('.loading', {opacity: 0, duration:1})
timelineMenu.to('.content', {yPercent: 150, duration:1})
}
}
loading.mouse = () => {
const menuHeight = $('.menu')[0].offsetHeight
$('.mouse').on('click', function () {
gsap.to(window, {duration: 2, scrollTo: menuHeight});
});
}
loading.all = () => {
loading.transition()
loading.mouse()
}
//nav
const nav = {}
const $nav = $('nav')
nav.color = function(){
const $menu = document.querySelector('.menu')
const menuHeight = $menu.offsetHeight
$(window).scroll(function () {
var scrollVal = $(this).scrollTop();
if (scrollVal < (menuHeight - 105)) {
$nav.addClass('white')
} else {
$nav.removeClass('white')
}
});
}
nav.all = () => {
nav.color()
}
//init
$(() => {
//common
clickSwitchClass.all()
clickToggleClass.all()
//others
loading.all()
nav.all()
});