forked from Suchitra-Sahoo/AgriLearnNetwork
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
101 lines (85 loc) · 2.8 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
95
96
97
98
99
100
101
let menuIcon = document.querySelectorAll('#menu-icon');
let navbar = document.querySelectorAll('.navbar');
let Contact = document.querySelectorAll('#contact');
let navContact = document.querySelectorAll('#nav--contact');
menuIcon.forEach(icon => {
icon.onclick = () => {
icon.classList.toggle('bx-x');
navbar.forEach(nav => nav.classList.toggle('active'));
}
});
// Add an "active" class to the clicked link
$('a[href*="#"]')
.not('[href="#"]')
.not('[href="#0"]')
.click(function(event) {
// Remove any existing "active" class from links
$('a').removeClass('active');
// Add "active" class to clicked link
$(this).addClass('active');
// Smooth scroll to target as before
if (
location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '')
&&
location.hostname == this.hostname
) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
if (target.length) {
event.preventDefault();
$('html, body').animate({
scrollTop: target.offset().top
}, 900, function() {
var $target = $(target);
$target.focus();
if ($target.is(":focus")) {
return false;
} else {
$target.attr('tabindex','-1');
$target.focus();
};
});
}
}
});
//when scroll on any section that section's corresponding hyperlink will be active and
// the previous activated hyperlink will be deactivated
$('section[id]').mouseover(function() {
var sectionId = $(this).attr('id');
var correspondingLink = $('a[href="#' + sectionId + '"]');
// Remove active class from all links
$('a').removeClass('active');
// Add active class to the corresponding link
correspondingLink.addClass('active');
});
// Set initial active link based on URL hash
$(document).ready(function() {
var hash = window.location.hash;
if (hash) {
$('a[href="' + hash + '"]').addClass('active');
}
let header=document.querySelectorAll('header');
header.classList.toggle('sticky',window.scrollY >100);
});
ScrollReveal({
reset:true,
distance:'80px',
duration:2000,
delay:200
});
ScrollReveal().reveal('.home-content, .heading',{ origin:'top' });
ScrollReveal().reveal('.home-img, .services-container, .portfolio-box, .contact form',{ origin:'bottom' });
ScrollReveal().reveal('.home-content h1, .about-img',{ origin:'left' });
ScrollReveal().reveal('.home-content p, .about-content',{ origin:'left' });
const typed=new Typed('.multiple-text',{
strings:['Sow','Learn','Grow' ],
typeSpeed:100,
backSpped:100,
backDelay:1000,
loop:true
});
const form = document.getElementById('contact-form');
form.addEventListener('submit', (event) => {
event.preventDefault();
form.reset();
});