L
L
lalabilli2019-12-27 10:06:57
JavaScript
lalabilli, 2019-12-27 10:06:57

Why do anchors not work properly in a vertical menu using js scrolling?

I use a script for smooth scrolling from anchors with an indent from above

$(document).ready(function() {
  $(".Anchor").on("click", "a", function(event) {
    event.preventDefault();
    var id = $(this).attr('href'),
      top = $(id).offset().top;
    $('div').animate({
      scrollTop: top - 200
    }, 500);
  });
});

On making a vertical menu with a scroll on the right (scrollspy from bootstrap 4), the menu began to behave extremely inadequately, jumping, scrolling further and not going there
Better to see once than hear a hundred times, link to the video
What's the matter, how to fix it?
Actually, this is how the menu behaves without a script, which also does not suit me very much

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sashabeep, 2019-12-27
@sashabeep

Syntax highlighting looks like something went wrong
l36q6c7jtj1twustkz5zlhbuu4w.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question