سؤال

I've gone through some of the tutorials here but still can't get a fix for my problem thus my posting this.

I was wondering if you could show me how to get my floating sharebar @ http://www.patchworkoftips.com/blackberry-messenger-voip-voice-calls/1983/ to only show only when the user has scrolled down like 100px of the page or gotten halfway in the article.

Here's my my sharebar css:

#search_bar {
    z-index: 1000;
    position: fixed !important;
    top: 0;
    width: 1082px;
    color: #FFF;
    background: #333;
    padding-top: 1px;
    padding-bottom: 1px;
    overflow: hidden;
    margin-left: auto;
    margin-right: auto;
}

Sorry I couldn't paste the sharebar code as it keeps disappearing here.

I'm a total newbie to using javascript and jquery so copy and paste solutions would be immensely appreciated.

هل كانت مفيدة؟

المحلول

$(window).on('scroll', function(){
    if($(window).scrollTop() > 100){ // The '100' can be set to what ever pixel height you want
         $('#search_bar').fadeIn('500'); // This shows the share bar
    }else{
         $('#search_bar').fadeOut('500'); // This hides the share bar
    }
});
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top