-
Notifications
You must be signed in to change notification settings - Fork 0
/
portfolio.js
48 lines (43 loc) · 1.59 KB
/
portfolio.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
// window.onload is typically needed to tell JavaScript
// to wait until the page is fully loaded before doing
// the function its been given
// This is important because things like the button
// need to load before we can attach functions to it
window.onload = function() {
// Getting the back to top button, and keeping it in a variable
const backToTopButton = document.getElementById("back-to-top");
// onclick to define what to do when the button is clicked
backToTopButton.onclick = function() {
// Using a slightly different way of `scrollTo`
// Using these options allows us to define position
// and type of scrolling
window.scrollTo({
top: 0,
left: 0,
behavior: 'smooth',
});
}
// Add an "event listener", in this case "scroll"
// When a "scroll" is performed, it will do the
// given function
window.addEventListener("scroll", function(event) {
// scrollY refers to the amount of
// vertical scrolling performed in pixels
if(this.scrollY > 250) {
// Remove the "hide" class when
// 250 or more has been scrolled
backToTopButton.classList.remove("hide");
} else {
// Add the "hide" class when less
// than 250 has been scrolled
backToTopButton.classList.add("hide");
}
});
};
function openLinksMenu() {
const openMenu = document.getElementById('inner-menu');
openMenu.classList.toggle("hide-contents");
};
window.addEventListener( 'load', function() {
flkty.resize();
});