-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjavascript.js
More file actions
19 lines (19 loc) · 828 Bytes
/
javascript.js
File metadata and controls
19 lines (19 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Code for Sticky Navbar
window.addEventListener("scroll", function () {
const header = document.querySelector("nav");
const ul = document.querySelector("ul");
const Dropdown1 = document.getElementById("Dropdown2");
header.classList.toggle("sticky", window.scrollY > 0);
Dropdown1.classList.toggle("Dropdown2", window.scrollY > 0);
ul.classList.toggle("ul", window.scrollY > 0);
});
// Code for slide1 parallx Effect
const slide1 = document.getElementById("slidecontent1");
const slide2 = document.querySelector("h1");
const slide3 = document.querySelector("button");
window.addEventListener("scroll", function () {
let value = window.scrollY;
slide1.style.marginTop = value * -0.7 + "px";
slide2.style.marginTop = value * -0.1 + "px";
slide3.style.marginTop = value * -0.1 + "px";
});