How to be with a smooth swipe scrolling when clicking on a link?

Hello! Put it on a website script from the Internet, for the smooth browsing to the desired location in the landing page, code like this:
$('a[href*="#"]:not([href="#"])').click(function() {
 if (location.pathname.replace(/^\//,") == this.pathname.replace(/^\//,") && location.hostname == this.hostname) {
 var target = $(this.hash);
 target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
 if (target.length) {
 $('html, body').animate({
 scrollTop: target.offset().top
 }, 1000);
 return false;
}
}
 });


I have a magnific-popup which also needs to link to the ID, and now when a man is pressed on the popup button, the browser begins to slowly drive up to this place, as it can be circumvented, there may be some exceptions to prescribe to the script turning it could not have been spared?

<a href="#cback" class="call-back button-call-back popup-with-move-anim">Request a callback</a>


the <menu>
 <ul class="menu">
 the <li><a href="#company">About us</a></li>
 the <li><a href="#production">Products</a></li>
 the <li><a href="#services">Services</a></li>
 the <li><a href="#question_answer">Question-answer</a></li>
 the <li><a href="#contacts">Contacts</a></li>
 the <li><a href="#ord-costing" class="popup-with-move-anim">Order cost calculation</a></li>
</ul>
 </menu>

Thank you in advance.
July 9th 19 at 12:48
2 answers
July 9th 19 at 12:50
Solution
$('a[href*="#"]:not([href="#"])').not('.popup-with-move-anim').click(function() {
 if (location.pathname.replace(/^\//,") == this.pathname.replace(/^\//,") && location.hostname == this.hostname) {
 var target = $(this.hash);
 target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
 if (target.length) {
 $('html, body').animate({
 scrollTop: target.offset().top
 }, 1000);
 return false;
}
}
});
$('a[href*="#ord-costing"]').click(function(e){
e.preventDefault();
 });

https://jsfiddle.net/Ln38fdno/
In General, it's easier opening a pop-up when PC hang on another block, for example, span or p.
Do not use a to do this a lot easier.
Zdravstujte, for some reason, this not exactly this class does not work, but putting back button-call-back is applied. But other is not working, for example, set the button class-ord-costing, and not writing it - again the same as before. - christophe3 commented on July 9th 19 at 12:53
: Fidle everything works. Post your code, will look. - caleb_Stehr commented on July 9th 19 at 12:56
: besides .not to add to e.preventDefaul. .not - does not scroll, and preventDefualt not generally affect the validity of the. - caleb_Stehr commented on July 9th 19 at 12:59
: overlooked, thank you! - christophe3 commented on July 9th 19 at 13:02
: please can you do now so that when you scroll to a certain block could be fixed top menu with the logo that was removed? And it is desirable that it was not a clone, because I used a clone of the block with a headhesive and there's no working anchor links(more smooth scrolling, was just jumping). Thank you in advance) - christophe3 commented on July 9th 19 at 13:05
When you download the menu page to give the class loading, and with best personal Finance change on scrolling. The example is here I have euroserviceltd.ru scripts merged into a single truth. Here is the code
$(window).scroll(function() {
 if ($('body').width() > 800) {
 if ($(this).scrollTop() >= 123 && $('menu').hasClass("loading")) {
$('menu').removeClass("loading").addClass("scrolling");
 } else if ($(this).scrollTop() < 123 && $('menu').hasClass("scrolling")) {
$('menu').removeClass("scrolling").addClass("loading");
}
}
 });

123 is the height at which to change the class.
loading relative position, and scrolling position fixed.
menu {
 &.loading {
 width: 100%;
 position: relative;
}
 &.scrolling {
 width: 100%;
 position: fixed;
 left: 0;
 top: 0;
}
}
- caleb_Stehr commented on July 9th 19 at 13:08
server it much here clone site euroservice.aydigital.webirus.ru - caleb_Stehr commented on July 9th 19 at 13:11
: thank you, understand the mechanics, now I will try. And one more question? - christophe3 commented on July 9th 19 at 13:14
well, since I started) - caleb_Stehr commented on July 9th 19 at 13:17
: Where to find such a slider?, maybe there's some kind of slider in mind?
How can I help? - christophe3 commented on July 9th 19 at 13:20
:
var heightblock = $('.header').height();
 $(window).scroll(function() {
 if ($(this).scrollTop() >= heightblock && $('.head-line').hasClass("loading")) {
$('menu').removeClass("loading").addClass("scrolling");
 } else if ($(this).scrollTop() < heightblock && $('.head-line').hasClass("scrolling")) {
$('menu').removeClass("scrolling").addClass("loading");
}
 });
- christophe3 commented on July 9th 19 at 13:23
it was, thank you very much)) - christophe3 commented on July 9th 19 at 13:26
The slider do not know the explanation is very vague. Try to look in the direction of a jquery accordion gorizontal in search engines. - caleb_Stehr commented on July 9th 19 at 13:29
: Yes, I also honestly do not understand why the client such samojedny slider, and the active slide will go back, I don't understand, well in General when you press the button, the background becomes the main. I reposte any of your project because You helped me)) - christophe3 commented on July 9th 19 at 13:32
nothing I have to repost) all the rules) - caleb_Stehr commented on July 9th 19 at 13:35
July 9th 19 at 12:52
//Smooth scrolling to the anchor
 $("body").on('click', '[href*="#"]', function(e){
 var fixed_offset = 100;
 $('html,body').stop().animate({ scrollTop: $(this.hash).offset().top - fixed_offset }, 1000);
e.preventDefault();
 });

Find more questions by tags jQueryJavaScript