-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
68 lines (50 loc) · 2.03 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
/*=============================================================
Authour URI: www.binarytheme.com
License: Commons Attribution 3.0
http://creativecommons.org/licenses/by/3.0/
100% To use For Personal And Commercial Use.
IN EXCHANGE JUST GIVE US CREDITS AND TELL YOUR FRIENDS ABOUT US
======================================================== */
(function ($) {
"use strict";
var mainApp = {
main_fun: function () {
/*====================================
CUSTOM LINKS SCROLLING FUNCTION
======================================*/
$('nav a[href*=#]').click(function () {
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) {
var targetOffset = $target.offset().top;
$('html,body')
.animate({ scrollTop: targetOffset }, 800); //set scroll speed here
return false;
}
}
});
/*====================================
NAV SCRIPTS
======================================*/
$(window).bind('scroll', function () {
var navHeight = $(window).height() -50;
if ($(window).scrollTop() > navHeight) {
$('nav').addClass('fixed');
}
else {
$('nav').removeClass('fixed');
}
});
},
initialization: function () {
mainApp.main_fun();
}
}
// Initializing ///
$(document).ready(function () {
mainApp.main_fun();
});
}(jQuery));