Jenny Pagan
Jenny Pagan

Reputation: 13

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?

Upvotes: 1

Views: 4400

Answers (1)

LucaDaniele
LucaDaniele

Reputation: 74

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;
}

Upvotes: 3

Related Questions