Skip to content

Commit 066ea35

Browse files
author
Jacob Krol
committed
Hard menu background transition
1 parent ac022fb commit 066ea35

File tree

1 file changed

+111
-0
lines changed

1 file changed

+111
-0
lines changed

scripts/js-main.js

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
2+
$(document).ready(function() {
3+
4+
set_toolbar_dim();
5+
animate_dropdowns();
6+
background_image();
7+
name_tag();
8+
disable_smooth_scroll();
9+
// dropdown_title_active(); KEEP DROPDOWN TITLE ACTIVE
10+
set_side_scroll_box();
11+
begin_side_scroll();
12+
13+
let menu = {
14+
background: $('#menu').css('background'),
15+
border: $('#menu').css('border')
16+
};
17+
18+
setInterval(function navbar() {
19+
if(!pageYOffset) {
20+
$('#menu').css({'background': 'none'})
21+
.css({'border': 'none'});
22+
} else {
23+
$('#menu').css({'background': menu.background});
24+
.css({'border': menu.border});
25+
}
26+
}, 1);
27+
28+
29+
});
30+
31+
function set_toolbar_dim() {
32+
//measure dimensions
33+
var menuHeight = $("#menu").css('padding-top').replace('px',''),
34+
iconMargin = Number($("#icon").css('margin-top').replace('px','')),
35+
imgdim = $("#menu")[0].clientHeight + "px",
36+
imgwid = $("img").width() * ($("#menu")[0].clientHeight / $("img").height());
37+
//adjust icon dimensions
38+
$("#icon").css({height: imgdim})
39+
.css({width: imgwid})
40+
.css({'margin-top': (iconMargin - menuHeight) + "px"})
41+
.css({'margin-bottom': (iconMargin - menuHeight) + "px"});
42+
//adjust link heights
43+
$('#menu a:not(#icon):not(.drop-content > a)').css('height', $('#menu').height()+'px');
44+
//place dropdowns below tags
45+
$('.drop-content').css('top', $('#menu').height());
46+
}
47+
48+
function animate_dropdowns() {
49+
$('.drop-box').on('mouseover', function() {
50+
$(this).children().slideDown(500);
51+
});
52+
$('.drop-box').on('mouseleave', function() {
53+
$('.drop-content').slideUp(300);
54+
});
55+
}
56+
57+
function dropdown_title_active() {
58+
$('.drop-content').on('mouseover', function() {
59+
$(this).parent().css('background', '#BBB')
60+
.css('color', 'black');
61+
});
62+
$('.drop-content').on('mouseleave', function() {
63+
$(this).parent().css('background', '');
64+
});
65+
}
66+
67+
function background_image() {
68+
$('.overlay').css('height', $(window).height());// - $('#menu').height());
69+
//$('.overlay').css('top', $('#menu').height());
70+
$('header').css('height', $(window).height());
71+
}
72+
73+
function name_tag() {
74+
$('#name-tag').css('top', ($('.overlay').height()-$('#name-tag').height())/2);
75+
}
76+
77+
function disable_smooth_scroll() {
78+
if(navigator.userAgent.match(/Trident\/7\./)) {
79+
// document.body.addEventListener("mousewheel", function() {
80+
// event.preventDefault();
81+
// window.scrollTo(0, window.pageYOffset - event.wheelDelta);
82+
// });
83+
$('body').on("mousewheel", function () {
84+
// remove default behavior
85+
event.preventDefault();
86+
87+
//scroll without smoothing
88+
var wheelDelta = event.wheelDelta;
89+
var currentScrollPosition = window.pageYOffset;
90+
window.scrollTo(0, currentScrollPosition - wheelDelta);
91+
});
92+
}
93+
}
94+
95+
function set_side_scroll_box() {
96+
$('.side-scroll-outer').css('width', $(window).width());
97+
$('.side-scroll-inner').css('width', 4*$(window).width());
98+
$('.side-scroll-inner .content-block').css('width', $(window).width());
99+
}
100+
101+
function begin_side_scroll() {
102+
var shiftVal = 0,
103+
numPanels = 4;
104+
setInterval(function side_scroll() {
105+
shiftVal += (shiftVal < (numPanels-1)*$(window).width() ? $(window).width() : -(numPanels-1)*$(window).width());
106+
// $('.side-scroll-outer').scrollLeft(shiftVal);
107+
108+
$('.side-scroll-outer').animate( {scrollLeft: shiftVal }, 1500 );
109+
}, 4000);
110+
}
111+

0 commit comments

Comments
 (0)