-
Notifications
You must be signed in to change notification settings - Fork 0
/
fadingNav.min.js
1 lines (1 loc) · 1.44 KB
/
fadingNav.min.js
1
!function(a){a.fn.fadingNav=function(b){var c,d,e,f,g,h,i,j=!1,k=a.extend({},a.fn.fadingNav.defaults,b);this.each(function(){return c=a(this),a(window).on("load scroll",function(){j=!0,i=!1,d=a(window).scrollTop(),f=k.bkgColor,h=k.itemHeight.height(),e=k.alpha,g=d/h,k.fadeOnHover===!0&&(c.on("mouseenter touchmove touchstart",function(){i=!0,c.css("background-color","rgba("+k.bkgColor+", 1)").addClass(k.fadeOnHoverClass)}),c.on("mouseleave touchend",function(){0===d||e>=g?c.css("background-color","rgba("+k.bkgColor+","+e+")").stop().delay(k.removeOnHoverClassDelay).queue(function(){c.removeClass(k.fadeOnHoverClass).dequeue()}):0!==d&&g>e&&c.css("background-color","rgba("+k.bkgColor+","+g+")").stop().delay(k.removeOnHoverClassDelay).queue(function(){c.removeClass(k.fadeOnHoverClass).dequeue()}),i=!1})),j===!0&&h>d&&i!==!0?(setTimeout(function(){0===d||e>=g?(f="rgba("+k.bkgColor+", "+e+")",c.css("background-color",f)):g>e&&(f="rgba("+k.bkgColor+","+g+")",c.css("background-color",f)),k.enableBreakPoint===!0&&(g>=k.breakPointValue?c.addClass(k.breakPointClass):g<k.breakPointValue&&c.removeClass(k.breakPointClass))},k.refreshRate),j=!1):j===!0&&d>=h&&i!==!0&&c.css("background-color","rgba("+k.bkgColor+", 1)")}),this})},a.fn.fadingNav.defaults={bkgColor:"0, 0, 0",alpha:0,itemHeight:a(window),refreshRate:50,fadeOnHover:!0,fadeOnHoverClass:"hover-class",removeOnHoverClassDelay:200,enableBreakPoint:!0,breakPointClass:"break-point",breakPointValue:.5}}(jQuery);