D
D
Daniil Postnov2017-09-20 16:53:50
JavaScript
Daniil Postnov, 2017-09-20 16:53:50

Why doesn't scrollTop work?

Locally, the animation works, it does not work after integration to Bitrix.
Except scrollTop everything from js file works

<nav class="top-line__nav nav">

          <div class="nav__button"></div>

          <div class="nav__content" style="display: none;">
            <a href="#services" class="nav__link scrollTo">Услуги</a>
            <a href="#special-offers" class="nav__link scrollTo">Предложения</a>
            <a href="#our-project" class="nav__link scrollTo">Портфолио</a>
            <a href="#about-us" class="nav__link scrollTo">О компании</a>
            <a href="#process-order" class="nav__link scrollTo">Процесс</a>
            <a href="#testimonials" class="nav__link scrollTo">Отзывы</a>
            <a href="/katalog/" class="nav__link">Магазин</a>
            <a href="#footer" class="nav__link scrollTo">Контакты</a>
          </div>
        </nav>


$(document).on('click','.scrollTo', function(e){

    e.preventDefault();
    var currentBlock = $(this).attr('href');
    var currentBlockOffset = $(currentBlock).offset().top;


    $('html,body').animate({
      scrollTop: currentBlockOffset - 150
    },1200)

    $('.nav__content').hide()
})

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lumore, 2017-09-23
@Lumore

The code is valid, most likely the js files are in conflict. Open the console, it should show an error.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question