-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathujprogram.js
160 lines (150 loc) · 5.48 KB
/
ujprogram.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
var elemek = [],
ticking = false;
function mobilmenu(){
document.getElementById("menuPontok").classList.toggle("mobilmenuclick");
}
function menuikonvaltas(){
document.getElementById("menugomb").classList.toggle("menuikonvaltas");
}
function mobilmenuhitel(){
document.getElementById("hiteltipusmenu").classList.toggle("hiteltipusclick");
}
function menuhitelvaltas(){
document.getElementById("hitel-gomb").classList.toggle("menuhitelvaltas");
}
function hivo(elem, x) {
if (x === undefined) {
x = elemek.length;
}
elemek[x] = new function () {
if (elem.length === undefined) {
elem = [elem];
}
this.el = elem;
this.eT = [];
this.eM = [];
this.eB = [];
this.eC = [];
(function (th) {
for (var i = 0, len = th.el.length; i < len; i++) {
var el = th.el[i];
if (getComputedStyle(el).position === "static") {
el.style.position = "relative";
}
if (getComputedStyle(el).position === "fixed" || el.offsetParent === null) {
th.eT[i] = el.offsetTop;
} else {
var elC = el;
th.eT[i] = 0;
do {
th.eT[i] += elC.offsetTop;
elC = elC.offsetParent;
}
while (elC !== document.body);
}
th.eM[i] = el.offsetHeight;
th.eB[i] = th.eT[i] + th.eM[i];
th.eC[i] = th.eT[i] + (th.eM[i] / 2);
}
})(this);
}
}
var sect = document.querySelectorAll("section"),
menuk = document.querySelectorAll("#menuPontok>li>a"),
kezdohatter = document.querySelector(".kezdohatter"),
tipusokHatter = document.querySelector("img.hatter"),
tipusok = document.querySelector("section.hiteltipusok"),
cons = document.querySelectorAll("div.cons>p");
window.onload = function () {
var tipusoktarolomag = document.querySelector("div.bg-wr").offsetHeight;
tipusok.style.height = tipusoktarolomag + "px";
if (tipusoktarolomag > window.innerHeight) {
tipusokHatter.style.top = 0;
} else {
tipusokHatter.style.bottom = 0;
}
hivo(sect);
for (var i = 0, len = elemek[0].el.length; i < len; i++) {
var el = elemek[0].el[i],
eM = elemek[0].eM[i];
if (el.parentNode.className !== "tarolo") {
var tarolo = document.createElement("div");
tarolo.className = "tarolo";
el.parentNode.appendChild(tarolo);
tarolo.appendChild(el);
tarolo.style.height = eM + "px";
tarolo.style.zIndex = i;
tarolo.style.backgroundColor = "white";
}
}
};
window.onresize = function () {
var tarolo = document.querySelectorAll(".tarolo");
tarolo.forEach((tar, i) => tar.style.height = sect[i].offsetHeight + "px")
}
window.onscroll = function () {
var wT = window.pageYOffset,
wM = window.innerHeight,
wB = wT + wM,
wC = wT + (wM / 2);
if (!ticking) {
requestAnimationFrame(sectionok);
ticking = true;
}
function sectionok(){
var x = 0;
for (var i = 1, len = elemek[x].el.length; i < len; i++) {
var e = elemek[x].el[i],
eT = elemek[x].eT[i],
eM = elemek[x].eM[i],
eB = elemek[x].eB[i],
eC = elemek[x].eC[i],
elemCentValt = -Math.abs((wC - eC) / ((eM + wM) / 2)) + 1;
//kezdohatter parralax
if (elemek[0].eB[0] > wT) {
kezdohatter.style.transform = "translateY(" + wT / 2 + "px)";
kezdohatter.style.willChange = "transform";
}
//menük színváltása scrollpostól függően
if (i > 0) {
if (eT < wB && eB > wT) {
menuk[i - 1].style.color = "rgba(" + (Math.round(elemCentValt * 8) + 247) + ", " + (Math.round(elemCentValt * 108) + 147) + ", " + (Math.round(elemCentValt * 225) + 30) + ", 1)";
menuk[i - 1].style.background =
"linear-gradient(to bottom,rgba(247,147,30," + elemCentValt.toFixed(2) + ") 85%, transparent)";
} else {
menuk[i - 1].style.color = "orange";
menuk[i - 1].style.background = "none";
}
}
//hajlítás effektus
var hajl, hajlx, tar = document.querySelectorAll("div.tarolo")[i];
if (eM > wM) {
hajl = (eT - wT) / wM;
} else {
hajl = (eB - wB) / eM;
}
if (hajl <= 0) {
hajl = 0;
}
if (hajl >= 1) {
hajl = 1;
}
hajlx = Math.pow(hajl, 2);
cons[i].innerHTML = hajl
if (hajl < 1 && hajl > 0) {
e.style.willChange = "transform";
e.style.transform = "rotateX(" + hajlx * 90 + "deg)";
tar.style.perspective = "100vh";
tar.style.perspectiveOrigin = "50% 0%";
tar.style.overflow = "hidden";
} else {
e.style.willChange = "auto";
e.style.transform = "none";
tar.style.perspective = "none";
}
e.style.transformOrigin = "top";
e.style.opacity = 1 - hajl;
}
ticking = false;
}
};