2016-03-15 45 views
1

其他關係,我有其中有許多其他功能的大功能,(但我不能擁有所有這些功能,因爲做出錯誤與我的其他腳本),因此我只需要這使操作的功能,這我需要;最近我幫着找一個功能,但我認爲這會錯過其中隱藏內容的其他功能,並顯示一個按鈕,我需要的。當我運行該腳本運行良好,但不顯示一個按鈕,也沒有隱藏的酒吧,當您返回到初始位置。我只測試了這個大腳本,以知道是否有我的錯誤和元素yep。查找的JavaScript

大腳本,您可以在這裏,太覺得這是什麼,我試圖做See the code and example

你可以看看什麼我想這個形象,這個問題上做的例子: See Picture of the problem

我現在的劇本是這樣的,效果很好,但錯過這兩個細節是進入大腳本。請幫幫我。

// JavaScript Document 

; 
jQuery(document).ready(function() { 
    "use strict"; 
    jQuery(window).scroll(function() { 
     var scrollTop = jQuery(window).scrollTop(); 
     var docHeight = jQuery(document).height(); 
     var winHeight = jQuery(window).height(); 
     var scrollPercent = (scrollTop)/(docHeight - winHeight); 
     var scrollPercentRounded = Math.round(scrollPercent * 100); 
     jQuery('#post_indicator').css('width', scrollPercentRounded + '%'); 
    }); 
    jQuery(window).scroll(function() { 
     if (jQuery('#pp_fixed_menu').val() == 1) 

     { 
      if (jQuery(this).scrollTop() >= 200) { 
       jQuery('.header_style_wrapper .above_top_bar').hide(); 
       jQuery('.extend_top_contact_info').hide(); 
       jQuery('.top_bar').addClass('scroll'); 
       jQuery('#post_info_bar').addClass('scroll'); 
      } else if (jQuery(this).scrollTop() < 200) { 
       jQuery('.header_style_wrapper .above_top_bar').show(); 
       jQuery('.extend_top_contact_info').show(); 
       jQuery('#custom_logo img').removeClass('zoom'); 
       jQuery('#custom_logo img').css('maxHeight', ''); 
       jQuery('#custom_logo').css('marginTop', parseInt(logoMargin) + 'px'); 
       jQuery('#menu_wrapper div .nav > li > a').css('paddingTop', menuPaddingTop + 'px'); 
       jQuery('#menu_wrapper div .nav > li > a').css('paddingBottom', menuPaddingBottom + 'px');; 
       jQuery('.top_bar').removeClass('scroll'); 
       jQuery('#post_info_bar').removeClass('scroll'); 
      } 
     } else { 
      if (jQuery(this).scrollTop() >= 200) { 
       jQuery('.header_style_wrapper').addClass('nofixed'); 
      } else { 
       jQuery('.header_style_wrapper').removeClass('nofixed'); 
      } 
     } 
    }); 

}); 
+1

更好地切換類(命名爲象,滾動出)對身體並使用CSS來切換其他元素的可見性/行爲。 –

回答

0

如果你想顯示按鈕(箭頭),你需要將其添加到您的HTML,那麼你可以使用這個腳本:

<!-- language: lang-js --> 

// JavaScript Document 

; 
jQuery(document).ready(function() { 
    "use strict"; 
    jQuery(window).scroll(function() { 
     var scrollTop = jQuery(window).scrollTop(); 
     var docHeight = jQuery(document).height(); 
     var winHeight = jQuery(window).height(); 
     var scrollPercent = (scrollTop)/(docHeight - winHeight); 
     var scrollPercentRounded = Math.round(scrollPercent * 100); 
     jQuery('#post_indicator').css('width', scrollPercentRounded + '%'); 
    }); 



    jQuery(window).scroll(function() { 
     var calScreenWidth = jQuery(window).width(); 
     if (jQuery(this).scrollTop() > 200) { 
      jQuery('#toTop').stop().css({ 
       opacity: 0.5, 
       "visibility": "visible" 
      }).animate({ 
       "visibility": "visible" 
      }, { 
       duration: 1000, 
       easing: "easeOutExpo" 
      }); 
     } else if (jQuery(this).scrollTop() == 0) { 
      jQuery('#toTop').stop().css({ 
       opacity: 0, 
       "visibility": "hidden" 
      }).animate({ 
       "visibility": "hidden" 
      }, { 
       duration: 1500, 
       easing: "easeOutExpo" 
      }); 
     } 
    }); 
    jQuery('#toTop, .hr_totop').on('click', function() { 
     jQuery('body,html').animate({ 
      scrollTop: 0 
     }, 800); 
    }); 


    jQuery(window).scroll(function() { 
     if (jQuery('#pp_fixed_menu').val() == 1) 

     { 
      if (jQuery(this).scrollTop() >= 200) { 
       jQuery('.header_style_wrapper .above_top_bar').hide(); 
       jQuery('.extend_top_contact_info').hide(); 
       jQuery('.top_bar').addClass('scroll'); 
       jQuery('#post_info_bar').addClass('scroll'); 
      } else if (jQuery(this).scrollTop() < 200) { 
       jQuery('.header_style_wrapper .above_top_bar').show(); 
       jQuery('.extend_top_contact_info').show(); 
       jQuery('#custom_logo img').removeClass('zoom'); 
       jQuery('#custom_logo img').css('maxHeight', ''); 
       jQuery('#custom_logo').css('marginTop', parseInt(logoMargin) + 'px'); 
       jQuery('#menu_wrapper div .nav > li > a').css('paddingTop', menuPaddingTop + 'px'); 
       jQuery('#menu_wrapper div .nav > li > a').css('paddingBottom', menuPaddingBottom + 'px');; 
       jQuery('.top_bar').removeClass('scroll'); 
       jQuery('#post_info_bar').removeClass('scroll'); 
      } 
     } else { 
      if (jQuery(this).scrollTop() >= 200) { 
       jQuery('.header_style_wrapper').addClass('nofixed'); 
      } else { 
       jQuery('.header_style_wrapper').removeClass('nofixed'); 
      } 
     } 
    }); 

}); 

當你向上滾動,酒吧不再隱瞞?我用這個小腳本,它隱藏它測試這裏的時候,我向上滾動