I've worked with <body>
and <div class="wrapper">
When popup opens ...
<body>
gets a height of 100% and an overflow:hidden
<div class="wrapper">
gets position:relative;overflow:hidden;height:100%;
I use JS/jQuery to get the actual scrollposition of the page and store the value as data-attribut to body
Then i scroll to the scrollposition in the .wrapper DIV (not in window)
Here is my solution:
JS/jQuery:
// when popup opens
$('body').attr( 'data-pos', $(window).scrollTop()); // get actual scrollpos
$('body').addClass('locked'); // add class to body
$('.wrapper').scrollTop( $('body').attr( 'data-pos' ) ); // let wrapper scroll to scrollpos
// when popup close
$("body").removeClass('locked');
$( window ).scrollTop( $('body').attr( 'data-pos' ));
CSS:
body.locked {position:relative;overflow:hidden;height:100%;}
body.locked .wrapper {position:relative;overflow:hidden;height:100%;}
It works well on both sides ... desktop & mobile (iOS).
body
right? – Choli