forked from rohythakur/rohythakur.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
66 lines (61 loc) · 2.64 KB
/
index.js
File metadata and controls
66 lines (61 loc) · 2.64 KB
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
$(window).on('resize', function() {
'use strict';
var element = document.querySelector('#banner'),
elHeight = 0,
elTop = 0,
dHeight = 0,
wHeight = 0,
wScrollCurrent = 0,
wScrollBefore = 0,
wScrollDiff = 0;
window.addEventListener('scroll', function () {
// Hide the displayed menu. If you want to scroll, you're obviously not interested in the options.
$('.navbar-collapse').collapse('hide');
$('.navbar-toggle').addClass('collapsed').blur();
if($(window).width() <= 768) {
elHeight = element.offsetHeight;
dHeight = document.body.offsetHeight;
wHeight = window.innerHeight;
wScrollCurrent = window.pageYOffset;
wScrollDiff = wScrollBefore - wScrollCurrent;
elTop = parseInt(window.getComputedStyle(element).getPropertyValue('top')) + wScrollDiff;
// scrolled to the very top; element sticks to the top
if(wScrollCurrent <= 0) {
element.style.top = '0px';
} // scrolled up; element slides in
else if(wScrollDiff > 0) {
element.style.top = (elTop > 0? 0 : elTop) + 'px';
} // scrolled down
else if(wScrollDiff < 0) {
// scrolled to the very bottom; element slides in
if(wScrollCurrent + wHeight >= dHeight - elHeight) {
element.style.top = ( ( elTop = wScrollCurrent + wHeight - dHeight ) < 0 ? elTop : 0 ) + 'px';
} // scrolled down; element slides out
else { element.style.top = ( Math.abs( elTop ) > elHeight ? -elHeight : elTop ) + 'px'; }
}
wScrollBefore = wScrollCurrent;
} //
else element.style.top = '0px';
});
}).resize();
// Floating label headings for the contact form
$(function() {$("body")
.on("input propertychange", ".form-item",function(e) {
$(this).toggleClass("form-item-filled",!! $(e.target).val());})
.on("focus", ".form-item",function() {
$(this).addClass("form-item-focused");})
.on("blur", ".form-item",function() {
$(this).removeClass("form-item-focused");});
});
// Highlight the top nav as scrolling occurs
$('body').scrollspy({target: '.navbar-fixed-top'})
// Closes the Responsive Menu on Menu Item Click
$('.navbar-collapse ul li a').click(function() {
$(".navbar-collapse").collapse('hide');});
// jQuery for page scrolling feature - requires jQuery Easing plugin
$(function() {$('body').on('click', 'a.scrollable', function(event) {
var $anchor = $(this);
$('html, body').stop().animate({scrollTop: $($anchor.attr('href')).offset().top},1500,'easeInOutExpo');
event.preventDefault();
});
});