#11065 was intented to avoid double scrollbars from a Reveal modal, but removing all scrollbars when the modal opens changes the page content width and the content shift. This is a regression of #7831.
The current solution is a mix between the two previous fixes:
* Modal may have a scrollbar or not, following its content height
* Body has no scrollbar and prevent any scroll
* Document may have a scrollbar, following its content height (controlled in JS)
Changes:
* add the `zf-has-scroll` global html modifer and toggle it on Reveal opening/closing
* always prevent scroll on body instead of html tag like in #10583
See https://github.com/zurb/foundation-sites/issues/10791#issuecomment-
377861523
Closes #7831
}
_addRevealOpenClasses() {
+ if ($(document).height() > $(window).height()) {
+ $('html').addClass('zf-has-scroll');
+ }
$('html').addClass('is-reveal-open');
}
_removeRevealOpenClasses() {
$('html').removeClass('is-reveal-open');
+ $('html').removeClass('zf-has-scroll');
}
/**
html.is-reveal-open {
position: fixed;
width: 100%;
- overflow: hidden;
+ overflow-y: hidden;
+
+ &.zf-has-scroll {
+ overflow-y: scroll;
+ }
+
+ body { // sass-lint:disable-line no-qualifying-elements
+ overflow-y: hidden;
+ }
}
// Overlay