*/
open(event, trigger) {
if (this.$element.hasClass('is-open') || this.isRevealed) { return; }
- var _this = this,
- $body = $(document.body);
+ var _this = this;
if (this.options.forceTo === 'top') {
window.scrollTo(0, 0);
* Fires when the off-canvas menu opens.
* @event OffCanvas#opened
*/
- $('body').addClass('is-off-canvas-open');
_this.$element.addClass('is-open')
this.$triggers.attr('aria-expanded', 'true');
this.$element.attr('aria-hidden', 'false')
.trigger('opened.zf.offcanvas');
+ // If `contentScroll` is set to false, add class and disable scrolling on touch devices.
+ if (this.options.contentScroll == false) {
+ $('body').addClass('is-off-canvas-open').on('touchmove', this._stopScrolling);
+ }
+
// If we have an overlay lets make it visible.
if (this.options.contentOverlay) {
- $('body').on('touchmove', this._stopScrolling);
this.$overlay.addClass('is-visible');
}
var _this = this;
- $('body').removeClass('is-off-canvas-open');
_this.$element.removeClass('is-open');
this.$element.attr('aria-hidden', 'true')
*/
.trigger('closed.zf.offcanvas');
+ // If `contentScroll` is set to false, remove class and re-enable scrolling on touch devices.
+ if (this.options.contentScroll == false) {
+ $('body').removeClass('is-off-canvas-open').off('touchmove', this._stopScrolling);
+ }
+
// Remove `is-visible` class from overlay.
if (this.options.contentOverlay) {
- $('body').off('touchmove', this._stopScrolling);
this.$overlay.removeClass('is-visible');
}
*/
contentOverlay: true,
+ /**
+ * Enable/disable scrolling of the main content when an off canvas panel is open.
+ * @option
+ * @example true
+ */
+ contentScroll: true,
+
/**
* Amount of time in ms the open and close transition requires. If none selected, pulls from body style.
* @option
<button class="close-button" aria-label="Close panel" type="button" data-close>
<span aria-hidden="true">×</span>
</button>
- <h3>This is a right off-canvas panel</h3>
+ <h3>This is a right off-canvas panel.</h3>
</div>
<div class="off-canvas position-top" id="offCanvasTop" data-off-canvas>
<button class="close-button" aria-label="Close panel" type="button" data-close>
<span aria-hidden="true">×</span>
</button>
- <h3>This is a bottom off-canvas panel</h3>
+ <h3>This is a bottom off-canvas panel.</h3>
</div>
<div class="off-canvas position-left" id="offCanvasLeftOverlap" data-off-canvas data-transition="overlap">
<h3>This is a bottom off-canvas panel with force-to set to bottom</h3>
</div>
+ <div class="off-canvas position-left" id="noScroll" data-off-canvas data-content-scroll="false">
+ <button class="close-button" aria-label="Close panel" type="button" data-close>
+ <span aria-hidden="true">×</span>
+ </button>
+ <h3>This is a left off-canvas panel with content scroll disabled.</h3>
+ </div>
+
<div class="off-canvas position-left" id="noOverlay" data-off-canvas data-content-overlay="false">
<button class="close-button" aria-label="Close panel" type="button" data-close>
<span aria-hidden="true">×</span>
</div>
<div class="button-group expanded">
+ <button type="button" class="button" data-toggle="noScroll">No scroll</button>
<button type="button" class="button" data-toggle="noOverlay">No overlay</button>
<button type="button" class="button" data-toggle="noCloseOnClick">No close on click</button>
</div>
</div>
<div class="button-group expanded">
+ <button type="button" class="button" data-toggle="noScroll">No scroll</button>
<button type="button" class="button" data-toggle="noOverlay">No overlay</button>
<button type="button" class="button" data-toggle="noCloseOnClick">No close on click</button>
</div>