-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
57 lines (41 loc) · 1.4 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
$(document).ready(function () {
$('#menu').click(function () {
$(this).toggleClass('fa-times');
$('.navbar').toggleClass('nav-toggle');
});
$(window).on('scroll load', function () {
$('#menu').removeClass('fa-times');
$('.navbar').removeClass('nav-toggle');
});
$('.portfolio .button-container .btn').click(function () {
let filter = $(this).attr('data-filter');
if (filter == 'all') {
$('.portfolio .image-container .box').show('400')
} else {
$('.portfolio .image-container .box').not('.' + filter).hide('200');
$('.portfolio .image-container .box').filter('.' + filter).show('400');
}
});
$('#theme-toggler').click(function () {
$(this).toggleClass('fa-sun');
$('body').toggleClass('dark-theme');
});
// smooth scrolling
$('a[href*="#"]').on('click', function (e) {
e.preventDefault();
$('html, body').animate({
scrollTop: $($(this).attr('href')).offset().top,
},
500,
'linear'
);
});
});
// When the user scrolls the page, execute myFunction
window.onscroll = function() {myFunction()};
function myFunction() {
var winScroll = document.body.scrollTop || document.documentElement.scrollTop;
var height = document.documentElement.scrollHeight - document.documentElement.clientHeight;
var scrolled = (winScroll / height) * 100;
document.getElementById("myBar").style.width = scrolled + "%";
}