-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
130 lines (118 loc) · 2.61 KB
/
index.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
const titles = $(".titles a"); //title set
const imgs = $(".imgs a"); //image set
//current banner and timmer
let curIndex = 0;
let timer = null;
//remove active styling
function removeActive() {
$(".titles a").each(function () {
$(".titles a").removeClass("active");
});
$(".imgs a").each(function () {
$(".imgs a").removeClass("active");
});
}
//switch banner
function changeBanner(index) {
removeActive();
$(".titles a").eq(index).addClass("active");
$(".imgs a").eq(index).addClass("active");
}
//auto play banner
function autoBanner() {
timer = setInterval(function () {
curIndex++;
if (curIndex > titles.length - 1) {
curIndex = 0;
}
changeBanner(curIndex);
}, 3000);
}
$(".titles a").each(function () {
$(this)
.mouseenter(function () {
curIndex = $(this).index();
changeBanner(curIndex);
clearInterval(timer);
})
.mouseleave(function () {
autoBanner();
});
});
autoBanner();
// navigation bar action
let headerAnchor = $("header nav ul li");
$(window).scroll(() => {
console.log($(window).scrollTop());
if ($(window).scrollTop() !== 0) {
$("header").css({
"background-color": "rgba(0,0,0,0.4)",
transition: "all .5s",
});
headerAnchor.each(() => {
$("a").css("color", "white");
});
} else {
$("header").css("background-color", "#57544d");
headerAnchor.each(() => {
$("a").css("color", "white");
});
}
});
//navigation bar action end
//People js
function setFocus() {
$(".item").each(function () {
$(".item").removeClass("focus");
});
//add focus class to the current selected
$(this).addClass("focus");
}
$(".item").each(function () {
$(".item").on("click", setFocus);
});
function setOpacity() {
$(".people-container").css({
opacity: "1",
transition: "all 1s",
});
}
$(window).scroll(() => {
if ($(window).scrollTop() > 1400) {
$(".food-title").animate(
{
opacity: 1,
},
1500
);
}
if ($(window).scrollTop() > 500) {
$(".overview-title, .people-title").animate(
{
opacity: 1,
},
1500
);
$(".card:eq(0)").css({
transform: "translateY(0%)",
transition: ".6s linear",
});
$(".card:eq(1)").css({
transform: "translateY(0%)",
transition: ".8s linear",
});
$(".card:eq(2)").css({
transform: "translateY(0%)",
transition: "1s linear",
});
}
if ($(window).scrollTop() > 1900) {
$("li").css({
transform: `translateX(${0}%)`,
transition: ".8s linear",
});
}
if ($(window).scrollTop() > 4000) {
setOpacity();
}
});