E
E
Evgeniy Gaidukov2020-04-25 01:01:53
css
Evgeniy Gaidukov, 2020-04-25 01:01:53

How to "fall in love" with the height of the block so that the button works?

People, how can you dodge so that both the button works when scrolling, and the height of .page__wrapper, due to which the button stops working, remains 100vh?

(commented out in codepen height)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anar Latifov, 2020-04-25
@Sevuz-Bek

Just use .scrollTop not on the window, but on the .page__wrapper itself.

let amountScrolled = 100;

    $(".page__wrapper").scroll(function() {
      if ( $(".page__wrapper").scrollTop() > amountScrolled ) {
        $('.arrow-up').fadeIn('slow');
      } else {
        $('.arrow-up').fadeOut('slow');
      }
    });

    $('.arrow-up').on('click', function() {
      // alert(111);
      $('.page__wrapper').animate({
        scrollTop: 0
      }, 700);
      return false;
    });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question