Improvements on navigator
This commit is contained in:
parent
7dcbe77c2d
commit
fe460c0a2e
11 changed files with 243 additions and 147 deletions
61
js/custom.js
61
js/custom.js
|
|
@ -1,4 +1,6 @@
|
|||
var scrolling = false;
|
||||
var navigatorOpen = false;
|
||||
var topButtonVisible = true;
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
|
|
@ -8,21 +10,72 @@ $(document).ready(function(){
|
|||
|
||||
|
||||
$(".navigator-toggle").click(function() {
|
||||
if (!scrolling){
|
||||
if (navigatorOpen){
|
||||
closeTopMenu();
|
||||
}else{
|
||||
openTopMenu();
|
||||
}
|
||||
navigatorOpen = !navigatorOpen;
|
||||
});
|
||||
|
||||
$(".topic").click(function() {
|
||||
closeTopMenu();
|
||||
});
|
||||
|
||||
function openTopMenu(){
|
||||
if (!scrolling && !navigatorOpen){
|
||||
scrolling = true;
|
||||
$(".navigator").slideDown( "slow", function() {
|
||||
scrolling = false;
|
||||
navigatorOpen = true;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(".navbar").mouseover(function() {
|
||||
if (!scrolling){
|
||||
function closeTopMenu(){
|
||||
if (!scrolling && navigatorOpen){
|
||||
scrolling = true;
|
||||
$('.navigator').slideUp( "slow", function() {
|
||||
scrolling = false;
|
||||
navigatorOpen = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function showTopButton(){
|
||||
console.log('showTopButton');
|
||||
if (!topButtonVisible){
|
||||
$('.top-button').show( "slow", function() {
|
||||
topButtonVisible = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function hideTopButton(){
|
||||
console.log('hideTopButton');
|
||||
if (topButtonVisible){
|
||||
$('.top-button').hide( "slow", function() {
|
||||
topButtonVisible = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var timeout = null;
|
||||
var navbarHeight = $('.navbar').height();
|
||||
|
||||
$(window).scroll(function () {
|
||||
if (!timeout) {
|
||||
timeout = setTimeout(function () {
|
||||
clearTimeout(timeout);
|
||||
timeout = null;
|
||||
if ($(window).scrollTop() >= navbarHeight) {
|
||||
closeTopMenu();
|
||||
showTopButton();
|
||||
}else{
|
||||
hideTopButton();
|
||||
}
|
||||
}, 250);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue