forked from Sdhandre/Netflix_Clone
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
108 lines (85 loc) · 3.02 KB
/
script.js
File metadata and controls
108 lines (85 loc) · 3.02 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
document.querySelectorAll('.faqbox').forEach(function (item) {
item.addEventListener('click', function () {
this.classList.toggle('active');
var answer = this.nextElementSibling;
if (answer.classList.contains('active')) {
answer.style.maxHeight = '0';
setTimeout(() => {
answer.classList.remove('active');
}, 200); // Adjust timing to match transition duration
} else {
answer.classList.add('active');
answer.style.maxHeight = answer.scrollHeight + 'px';
}
});
});
const dropdownButton = document.querySelector('.btn');
const dropdownContent = document.querySelector('.dropdown-content');
console.log(dropdownButton, dropdownContent);
dropdownButton.addEventListener('click', function (event) {
event.stopPropagation();
dropdownContent.classList.toggle('show');
});
window.addEventListener('click', function (event) {
if (!event.target.matches('.btn')) {
if (dropdownContent.classList.contains('show')) {
dropdownContent.classList.remove('show');
}
}
});
dropdownContent.addEventListener('click', function (event) {
event.stopPropagation();
});
document.addEventListener('DOMContentLoaded', function () {
var egetStartedButton = document.getElementById("egetStartedButton");
if (egetStartedButton) {
egetStartedButton.addEventListener("click", function () {
window.location.href = "https://www.netflix.com/in";
});
}
var hindigetStartedButton = document.getElementById("hindigetStartedButton");
if (hindigetStartedButton) {
hindigetStartedButton.addEventListener("click", function () {
window.location.href = "https://www.netflix.com/in-hi/";
});
}
var esignInButton = document.getElementById("esignInButton");
if (esignInButton) {
esignInButton.addEventListener("click", function () {
window.location.href = "https://www.netflix.com/login";
});
}
var hindisignInButton = document.getElementById("hindisignInButton");
if (hindisignInButton) {
hindisignInButton.addEventListener("click", function () {
window.location.href = "https://www.netflix.com/login";
});
}
});
var scrollToTopBtn = document.getElementById("scrollToTopBtn");
window.onscroll = function() {
scrollFunction();
};
function scrollFunction() {
if (
document.documentElement.scrollTop > 695
) {
scrollToTopBtn.style.display = "block";
} else {
scrollToTopBtn.style.display = "none";
}
}
scrollToTopBtn.addEventListener("click", function() {
topFunction();
});
function topFunction() {
var currentPosition = document.documentElement.scrollTop || document.body.scrollTop;
var scrollStep = Math.round(-currentPosition / 30);
function smoothScroll() {
if (document.documentElement.scrollTop !== 0 || document.body.scrollTop !== 0) {
window.scrollBy(0, scrollStep);
requestAnimationFrame(smoothScroll);
}
}
smoothScroll();
}