-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
40 lines (27 loc) · 1.01 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
$(document).ready(function(){
$('#menu').click(function(){
$(this).toggleClass('fa-times');
$('.navbar').toggleClass('nav-toggle');
});
$('#login').click(function(){
$('.login-form').addClass('popup');
});
$('.login-form form .fa-times').click(function(){
$('.login-form').removeClass('popup');
});
$(window).on('load scroll',function(){
$('#menu').removeClass('fa-times');
$('.navbar').removeClass('nav-toggle');
$('.login-form').removeClass('popup');
$('section').each(function(){
let top = $(window).scrollTop();
let height = $(this).height();
let id = $(this).attr('id');
let offset = $(this).offset().top - 200;
if(top > offset && top < offset + height){
$('.navbar ul li a').removeClass('active');
$('.navbar').find(`[href="#${id}"]`).addClass('active');
}
});
});
});