-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
80 lines (61 loc) · 1.93 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
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
'use strict';
(function() {
// invocations
preloader();
burgerCloseIcon();
animation();
showModal();
//change burger close icon
function burgerCloseIcon() {
let btn = document.querySelector(".navbar-toggler");
let icon = document.querySelector(".navbar-toggler-icon");
btn.addEventListener("click", function() {
icon.classList.toggle('close-img');
});
}
//////preloader
function preloader() {
document.body.onload = function() {
setTimeout(function() {
let preloader = document.querySelector(".preloader");
if (!preloader.classList.contains('done')) {
preloader.classList.add('done');
}
}, 1000)
}
};
//animation after loading
function animation() {
let tl = new TimelineMax();
tl
.from(".header", 1, {
y: '-300%',
delay: 1
}, )
.staggerFrom(".anim", .5, {
y: '150',
opacity: 0
}, 0.4, "-=0.1")
.from(".anchor", 0.1, {
scale: 0
}, "-=1.6")
}
///animation modals on buttons
function showModal() {
let modals = document.querySelectorAll(".modall");
let buttons = document.querySelectorAll(".hero__adapt-btn");
let closeBtns = document.querySelectorAll(".close-modal");
buttons.forEach((el) => el.addEventListener("click", show));
closeBtns.forEach((el) => el.addEventListener("click", hide));
function show() {
modals.forEach((el) => {
if (el.dataset.attr === this.dataset.attr) {
el.style.transform = ("translateY(0)");
}
})
}
function hide() {
this.parentNode.style.transform = ("translateY(-500%)");
}
}
})();