mirror of
https://github.com/WatchOutNewsAgency/wona.github.com.git
synced 2026-01-01 01:16:26 +00:00
Title and navbar fixes
This commit is contained in:
@ -6,6 +6,7 @@ $(function() {
|
||||
$(this).addClass(imgClass);
|
||||
})
|
||||
|
||||
/*
|
||||
var switchPos = $('#new-articles').position().top + $('#new-articles').height();
|
||||
|
||||
$(window).scroll(function() {
|
||||
@ -17,6 +18,70 @@ $(function() {
|
||||
$(".navbar-wrapper").removeClass("darken");
|
||||
}
|
||||
});
|
||||
*/
|
||||
|
||||
;(function($, window, document, undefined) {
|
||||
'use strict';
|
||||
|
||||
var elSelector = '.navbar-wrapper',
|
||||
elClassHidden = 'navbar--hidden',
|
||||
throttleTimeout = 250,
|
||||
$element = $( elSelector );
|
||||
|
||||
if(!$element.length) return true;
|
||||
|
||||
var $window = $( window ),
|
||||
wHeight = 0,
|
||||
wScrollCurrent = 0,
|
||||
wScrollBefore = 0,
|
||||
wScrollDiff = 0,
|
||||
$document = $( document ),
|
||||
dHeight = 0,
|
||||
|
||||
throttle = function(delay, fn) {
|
||||
var last, deferTimer;
|
||||
return function() {
|
||||
var context = this, args = arguments, now = +new Date;
|
||||
if( last && now < last + delay ) {
|
||||
clearTimeout( deferTimer );
|
||||
deferTimer = setTimeout( function(){ last = now; fn.apply( context, args ); }, delay );
|
||||
|
||||
}
|
||||
else {
|
||||
last = now;
|
||||
fn.apply( context, args );
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
$window.on( 'scroll', throttle( throttleTimeout, function() {
|
||||
dHeight = $document.height();
|
||||
wHeight = $window.height();
|
||||
wScrollCurrent = $window.scrollTop();
|
||||
wScrollDiff = wScrollBefore - wScrollCurrent;
|
||||
|
||||
if(wScrollCurrent <= 0) { // scrolled to the very top; element sticks to the top
|
||||
$element.removeClass(elClassHidden);
|
||||
$element.removeClass(elClassTop);
|
||||
}
|
||||
|
||||
else if(wScrollDiff > 10 && $element.hasClass(elClassHidden)) // scrolled up; element slides in
|
||||
$element.removeClass( elClassHidden );
|
||||
|
||||
else if(wScrollDiff < -10) {// scrolled down
|
||||
if(wScrollCurrent + wHeight >= dHeight && $element.hasClass(elClassHidden)) // scrolled to the very bottom; element slides in
|
||||
$element.removeClass( elClassHidden );
|
||||
|
||||
else // scrolled down; element slides out
|
||||
$element.addClass( elClassHidden );
|
||||
|
||||
}
|
||||
|
||||
wScrollBefore = wScrollCurrent;
|
||||
}));
|
||||
|
||||
|
||||
})( jQuery, window, document );
|
||||
});
|
||||
|
||||
function onYouTubeIframeAPIReady() {
|
||||
@ -38,3 +103,4 @@ function onYouTubeIframeAPIReady() {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user