-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
114 lines (101 loc) · 2.32 KB
/
app.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
const header = document.querySelector("header");
const sectionOne = document.querySelector(".home-intro, .gallery-intro");
const sliders = document.querySelectorAll(".slide-in");
const sectionOneOptions = {
rootMargin: "-200px 0px 0px 0px"
};
const sectionOneObserver = new IntersectionObserver(function(
entries,
sectionOneObserver
) {
entries.forEach(entry => {
if (!entry.isIntersecting) {
header.classList.add("nav-scrolled");
} else {
header.classList.remove("nav-scrolled");
}
});
},
sectionOneOptions);
sectionOneObserver.observe(sectionOne);
// For sliders
const appearOptions = {
threshold: 0,
rootMargin: "0px 0px -250px 0px"
};
const appearOnScroll = new IntersectionObserver(function(
entries,
appearOnScroll
) {
entries.forEach(entry => {
if (!entry.isIntersecting) {
return;
} else {
entry.target.classList.add("appear");
appearOnScroll.unobserve(entry.target);
}
});
},
appearOptions);
sliders.forEach(slider => {
appearOnScroll.observe(slider);
});
document.addEventListener('DOMContentLoaded', function() {
let currDate = document.querySelectorAll('#current-date');
currDate.forEach(item => {
item.textContent =currentDate();
})
});
function currentDate() {
let daysName=[
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday'
];
let months =[
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December'
]
let date =new Date();
let dayName = daysName[date.getDay()];
let monthName = months[date.getMonth()];
let year = date.getFullYear();
let fullDate = `${dayName}, ${date.getDate()} ${monthName} ${year}`;
return fullDate;
}
// Image Slider
let slideIndex = 0;
showSlides();
function showSlides()
{
let slides = document.getElementsByClassName("image-sliderfade");
let dots = document.getElementsByClassName("dot");
for (let i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
slideIndex++;
if (slideIndex > slides.length)
{
slideIndex = 1;
}
for ( let i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex - 1].style.display = "block";
dots[slideIndex - 1].className += " active";
setTimeout(showSlides, 3000);
}