I
I
Igor Kaspersky2015-11-11 21:46:43
css
Igor Kaspersky, 2015-11-11 21:46:43

Show item on scroll?

Hello everyone, here is the code when scrolling, an object appears, but I can’t figure out how to make it appear in a certain place , and disappear if you scroll back, what can you tell?

$(document).ready(function(){

   $(window).scroll(function(){
      var scroll = $(this).scrollTop();

    if (scroll > $('.fix').offset().top-($(window).height()/2)){
      $(".fix").css({
                        console.log(scroll);	
      'transition' : 'all 1s ease',
      'opacity' : '1'});		
    }

  });
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Kondratiev, 2015-11-11
@HHabar

I remembered myself at the beginning of the journey).
You already have one if.
You need another one to check

if (  true ===  'листаешь обратно'  ) {
        // opacity = 0
}

Something like this if I understand you correctly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question