-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript1.js
95 lines (80 loc) · 2.57 KB
/
script1.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
(function () {
// invocation
preloader();
smoothScrollLinks();
toTop();
showTitle();
AOS.init();
//////preloader
function preloader() {
document.body.onload = function () {
setTimeout(function () {
var preloader = document.querySelector(".preloader");
if (!preloader.classList.contains('done')) {
preloader.classList.add('done');
}
}, 1000)
}
};
////smoothScroll
function smoothScrollLinks() {
let nav = document.querySelector(".navbar-nav");
nav.querySelectorAll('a[href^="#"]').forEach(link => {
link.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
let btnHero = document.querySelector(".hero__toscroll");
btnHero.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
}
/// button to top
function toTop() {
var buttonTop = document.querySelector("#btn-up");
window.onscroll = function () {
if (document.body.scrollTop > 400 || document.documentElement.scrollTop > 400) {
buttonTop.style.opacity = "1";
} else {
buttonTop.style.opacity = "0";
}
}
buttonTop.addEventListener("click", function (e) {
e.preventDefault();
document.querySelector(".hero").scrollIntoView({
behavior: 'smooth'
});
})
}
//show text in example of portfolio
function showTitle() {
let tl = new TimelineMax();
tl
.from(".navbar-brand", .5, {
x: '-300%',
}, delay = .5)
.staggerFrom(".nav-link", .5, {
y: '-50',
opacity: 0
}, 0.1, "-=0.20")
.from('#title', 2, {
y: '-300%',
ease: Bounce.easeOut
})
.from('.hero__subtitle', .5, {
y: '100',
opacity: 0
}, "-=1")
.from('.hero__toscroll', 1, {
backgroundColor: "rgba(52, 58, 64)",
opacity: .8,
borderRadius: "5px"
}, "-=2")
}
})();