-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.js
94 lines (82 loc) · 2.66 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
const locoScroll = new LocomotiveScroll({
el: document.querySelector("#main"),
smooth: true
});
// ------------------------------------------
swiper = () => {
var swiper = new Swiper(".mySwiper", {
slidesPerView: "auto",
loop: true,
centeredSlides: true,
spaceBetween: 100,
});
}
swiper();
// ------------------------------------------
h1 = () => {
var h1s = document.querySelectorAll('.cntpart1 h1');
var p = document.querySelector('.cntpart1 p');
var img = document.querySelector('.cntpart2');
// h1s.addEventListener("click",function(){
// h1s.style.borderLeft = '6px solid orangered';
// h1s.style.color = 'lightgray';
// })
h1s.forEach(function (h1) {
var text = h1.getAttribute("data-text")
var image = h1.getAttribute("data-src")
h1.addEventListener('click', function () {
p.textContent = text;
img.style.backgroundImage = `url(${image})`
});
});
}
h1();
// --------------------------------------------
page4 = () => {
var elemC = document.querySelector("#elem-container")
var fixed = document.querySelector("#fixed")
elemC.addEventListener("mouseenter", function () {
fixed.style.display = "flex"
})
elemC.addEventListener("mouseleave", function () {
fixed.style.display = "none"
})
var elems = document.querySelectorAll(".elem")
elems.forEach(function (e) {
e.addEventListener("mouseenter", function () {
var image = e.getAttribute("data-image")
fixed.style.backgroundImage = `url(${image})`
var video = e.getAttribute("data-video")
fixed.innerHTML = `<video autoplay loop muted src="${video}" type="video/mp4"></video>`;
})
})
}
if (window.innerWidth > 768) { // 768px is a common breakpoint for mobile devices
page4();
}
// -------------------------------------------------------
menu = ()=> {
var menu = document.querySelector("nav h3")
var full = document.querySelector("#full-scr")
var navimg = document.querySelector("nav img")
var close = document.querySelector("#close")
menu.addEventListener("click", function () {
full.style.top = 0
full.style.opacity = 1
navimg.style.opacity = 0
})
close.addEventListener("click", function(){
full.style.top = "-100%"
full.style.opacity = 0
navimg.style.opacity = 1
})
}
menu();
// --------------------------------------------------------
loader = ()=> {
var loader = document.querySelector("#loader")
setTimeout(function () {
loader.style.top = "-100%"
}, 4200)
}
loader();