Skip to content

Instantly share code, notes, and snippets.

@awhedbee22
Last active October 12, 2017 10:30
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awhedbee22/2915bf6dd533244d66d4 to your computer and use it in GitHub Desktop.
Save awhedbee22/2915bf6dd533244d66d4 to your computer and use it in GitHub Desktop.
Stop body from scrolling with Foundation 5 Reveal-Modal
$(".reveal-modal").on("open", function () {
$("body").addClass("modal-open");
});
$('.close-reveal-modal').bind("click touchstart", function () {
$('body').removeClass('modal-open');
});
body.modal-open {
overflow: hidden;
position: fixed;
}
.reveal-modal {
overflow-y: auto;
height: 100%;
position: fixed;
}
@of6
Copy link

of6 commented Feb 23, 2015

FYI, the open event binding is going to be depreciated in ver 5.4
Best to use the namedspaced events open.fndtn.reveal, opened.fndtn.reveal, close.fndtn.reveal and closed.fndtn.reveal

$('.reveal-modal').on('open.fndtn.reveal', '[data-reveal]', function () {
    $('body').addClass('modal-open');
});
$('.reveal-modal').on('close.fndtn.reveal', '[data-reveal]', function () {
    $('body').removeClass('modal-open');
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment