I have links in navigation panel on my site. When i am clicking at any link, it triggers slow scrolling to needed section of my site,
There is a script:
$('.header__navigation a[href^="#"]').on('click', function (e) {
e.preventDefault();
var id = $(this).attr('href');
var top = $(id).offset().top;
$('body,html').animate({scrollTop: top - 10}, 700);
});
After this, If i am trying to open MP, and then, when i am close the popup by clicking X-button or clicking on background, browser scrolls to top of page.
Here is initialization of MP:
$('.teacher-popup-trigger').magnificPopup({
type: 'inline',
fixedBgPos: true,
fixedContentPos: false,
closeOnBgClick: true,
closeMarkup: '<button title="%title%" type="button" class="mfp-close' +
' popup-close-button">啸</button>',
midClick: false/*,
alignTop: true*/
});
HTML of link:
<a href="#teacher-popup1" class="ourTeachers__slider_item-link teacher-popup-trigger">
//content of link
</a>
HTML of popup:
<div class="teacher-popup mfp-hide" id="teacher-popup1">
//popup content.
</div>
Does anybody knows what is the problem? When i am trying to open MP without clicking on link in navigation, it is all OK.
I tried this in Chrome, Opera. Firefox and even in I.E. 11...result it the same in all this browsers.
Maybe the problem is with swiper-slider. My links that open pop-ups are parts of slides. I mean each slide is a link to needed pop-up. Help me please. Thanks!
Did you try to set autoFocusLast option to false?
Magnific Popup will try to focus back to the last element that you focused before open popup by default.
boatkung
Did you try to set
autoFocusLastoption to false?
Magnific Popup will try to focus back to the last element that you focused before open popup by default.
A lot of thanks. That helped me! Thank you again. I've solve my problem earlier in other way(I've made custom popup without plugin). But now I tried your advice and I am happy :)
Most helpful comment
Did you try to set
autoFocusLastoption to false?Magnific Popup will try to focus back to the last element that you focused before open popup by default.