jQuery(function($) { //↓fade spead var FadeInTime = 350; //↓fixed start position manual /*var ptop = 180;*/ //fixed start position auto var ptop = $('header').offset().top + $('header').outerHeight(); var ou = $('#blt_global_container'); var al = $('.blt_children'); var ba = $('#blt_child1'); var bb = $('#blt_child2'); var bc = $('#blt_child3'); var bd = $('#blt_child4'); var be = $('#blt_child5'); var bf = $('#blt_child6'); var bg = $('#blt_child7'); var bh = $('#blt_child8'); var parent = $('div.blt_global_parents>div>ul>li'); var flg = $(1); var target = document.querySelectorAll('#blt_global_container > div > div > .blt_global_parents > div > ul > li'); $(document).ready( function(){ //parent width setting var linum = $('#blt_global_container > div > div > .blt_global_parents > div > ul > li').length; if(linum < 8){ linum = 100 / linum; var numstr = linum + "%"; $(target).each( function(i){ this.style.width = numstr; }); }else{ $(target).each( function(i){ this.style.width = '12.5%'; }); } //reload position check and setting var scroll = $(window).scrollTop(); if(scroll > ptop){ $(ou).hide(); $(ou).addClass("fixed"); setTimeout(function() { $(ou).fadeIn(FadeInTime); },50); if(flg === 1){ $(ou).removeClass("fixed"); flg=0; } }else{ $(ou).removeClass("fixed"); } }); //scroll fixed $(window).on("scroll", function() { var scroll = $(window).scrollTop(); if(scroll > ptop){ if(flg === 1){ $(ou).hide(); $(ou).addClass("fixed"); setTimeout(function() { $(ou).fadeIn(FadeInTime); },50); flg=0; } } if((scroll < ptop)){ $(ou).removeClass("fixed"); flg=1; } }); });