Skip to content

Instantly share code, notes, and snippets.

@AlekseyDevksh
Created March 20, 2017 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlekseyDevksh/3568ea47dc71aba14d24ced4ee56ee61 to your computer and use it in GitHub Desktop.
Save AlekseyDevksh/3568ea47dc71aba14d24ced4ee56ee61 to your computer and use it in GitHub Desktop.
modal safari
var scrollPos = 0;
$('.modal')
.on('show.bs.modal', function (){
scrollPos = $('body').scrollTop();
$('body').css({
overflow: 'hidden',
position: 'fixed',
top : -scrollPos
});
})
.on('hide.bs.modal', function (){
$('body').css({
overflow: '',
position: '',
top: ''
}).scrollTop(scrollPos);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment