-
Notifications
You must be signed in to change notification settings - Fork 0
/
scripts.js
56 lines (46 loc) · 1.33 KB
/
scripts.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
$(document).ready(function(){
$('nav a[href^="#"]').on('click', function(e) {
//Smooth Scroll Script
e.preventDefault();
var target = this.hash;
var $target = $(target);
$('html, body').stop().animate({
'scrollTop': $target.offset().top
}, 900, 'swing', function() {
window.location.hash = target;
});
});
//Gallery Sorter Script
$('ul#filter a').click(function() {
var filterName = $(this).text().toLowerCase().replace(' ', '-');
if (filterName == "all") {
$('ul#portfolio li.hidden').fadeIn('slow').removeClass('hidden');
}
else {
$('ul#portfolio li').each(function() {
if(!$(this).hasClass(filterName)){
$(this).fadeOut('normal').addClass('hidden');
}
else {
$(this).fadeIn('normal').removeClass('hidden');
}
})
}
return(false);
})
//highlight on scroll/click
$('nav li a').on('click', function(event) {
$(this).parent().find('a').removeClass('active');
$(this).addClass('active');
});
var scrollBottom = $(window).scrollTop() + $(window).height()
$(window).on('scroll', function() {
$('.target').each(function() {
if($(window).scrollTop()+$(window).height() >= $(this).offset().top + 100) {
var id = $(this).attr('id');
$('nav a').removeClass('active');
$('nav a[href="#'+ id +'"]').addClass('active');
}
});
});
})