Answer the question
In order to leave comments, you need to log in
How to stop scrolling when a link is clicked?
There is a link page .
There are 4 blocks. In block 1 there are links to block2, block 3, block 4.
If you are in block 1, then when you start scrolling, refinement to block 2 is triggered, then refinement is turned off.
There are also links to the corresponding blocks.
The problem is that when you follow a link to blocks 3 or 4, the debugging is triggered and transfers back to block 2.
I can’t figure out how to correctly hang a ban on debugging when clicking on the link so that when you click on the link, it doesn’t return back to the block 2.
Answer the question
In order to leave comments, you need to log in
Redesigned via onwheel jsfiddle.net/d4qdn089/8
Minus: if you follow the link and then scroll up, then when block 1 is reached, fine-tuning to block 2 is triggered. Solution: separate the bottom scroll, but I'm too lazy.
If we are in the first block, it finishes up to 2 of the second.
var firstHeight = $('#block1').height();
var scrollNow = $(this).scrollTop();
var target = $('#block2');
$( window ).scroll(function() {
scrollNow <= firstHeight ? $('html,body').animate({
scrollTop: target.offset().top
}, 1000);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question