-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
executable file
·46 lines (40 loc) · 1.38 KB
/
script.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
const curry = f => (...args) =>
args.length >= f.length ? f(...args) : curry(f.bind(f, ...args));
const compose = (f, g) => x => f(g(x));
const composeN = (...fns) => (...args) =>
fns.reverse().reduce((x, f) => f.apply(f, [].concat(x)), args);
// FOR CREATING A NAV ICON HIGHLIGHT IF SCROLLED
// let section = document.querySelectorAll('section');
// let menu = document.querySelectorAll('header nav a');
// window.onscroll = () => {
// section.forEach(i => {
// let top = window.scrollY;
// let offset = i.offsetTop - 150;
// let height = i.offsetHeight;
// let id = i.getAttribute('id');
// if (top >= offset && top < offset + height) {
// menu.forEach(link => {
// link.classList.remove('active');
// document.querySelector('header nav a[href*=' + id + ']')
// .classList.add('active');
// });
// }
// });
// };
function reveal() {
var reveals = document.querySelectorAll(".reveal");
for (var i = 0; i < reveals.length; i++) {
var windowHeight = window.innerHeight;
var elementTop = reveals[i].getBoundingClientRect().top;
var elementVisible = 60;
if (elementTop < windowHeight - elementVisible) {
reveals[i].classList.add("active");
} else {
reveals[i].classList.remove("active");
}
}
}
/**
* Back to top button
*/
window.addEventListener("scroll", reveal);