-
Notifications
You must be signed in to change notification settings - Fork 0
/
home.js
36 lines (36 loc) · 1.19 KB
/
home.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
$(function () {
$(document).scroll(function () {
var $nav = $(".navbar-fixed-top");
$nav.toggleClass('scrolled', $(this).scrollTop() > $nav.height()*2);
showScrollTop()
});
$(document).ready(function() {
var $nav = $(".navbar-fixed-top");
if($(this).scrollTop() > $nav.height()*2) $nav.addClass('scrolled');
showScrollTop();
});
$(".navbar-nav a").click(function(e) {
e.preventDefault();
});
$(".navbar-toggle").click(function() {
if($(this).hasClass("collapsed")) $(".navbar-fixed-top").addClass('opennav');
else $(".navbar-fixed-top").removeClass('opennav');
});
$(".navbar-fixed-top a").click(function(e) {
e.preventDefault();
if($(this).parents(".navbar-fixed-top").hasClass('opennav')) $(".navbar-toggle").click();
});
$(".scrollTopBtn").click(function() {
$('html,body').unbind().animate({scrollTop: 0},'slow');
});
});
function scrollToDiv(id,offset){
$('html,body').unbind().animate({scrollTop: $("#"+id).offset().top-offset},'slow');
};
function showScrollTop(){
if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
$('.scrollTopBtn').show(200);
} else {
$('.scrollTopBtn').hide(200);
}
}