Search code examples
jquerymagnific-popup

when magnific popup open page scroll top


I have a problem with magnific popup. when I click on button - modal window open and page scroll to top. When close modal window - position of scroll return position reverse. I dont won't to page scroll top. maybe anybody has same problem?


Solution

  • Set fixedContentPos option of MagnificPopup to false. By default it's set to auto and when you click the button the page scrolls to top.

    $('#popupid').magnificPopup({ fixedContentPos = false, //Options... });
    

    EDIT

    Try to use this option too (it adds the class when popup gets open and delete it when popup gets closed):

    callbacks: {
        open: function() {
           jQuery('body').addClass('magnificpopupnoscroll');
        },
        close: function() {
           jQuery('body').removeClass('magnificpopupnoscroll');
        }
    }
    

    And add this css class:

    body.magnificpopupnoscroll{
       overflow-y: hidden !important;
    }