</head>
<body>
+ <div class="off-canvas-wrapper" data-off-canvas-wrapper>
+
{{> off-canvi}}
<div class="main-content" data-off-canvas-content>
{{> footer}}
</div>
+ </div>
+
<script src="assets/js/vendor.js"></script>
<script src="assets/js/foundation.js"></script>
<script src="assets/js/docs.js"></script>
## Setup
-Create an off-canvas menu with the class `.off-canvas` and the attribute `data-off-canvas`. The menu also needs a positioning class, which can be `.position-left` or `.position-right`. Make sure the off-cavnas also has a unique ID so it can be targeted.
+To start, create a wrapper to house your entire page. It has the class `.off-canvas-wrapper` and the attribute `data-off-canvas-wrapper`.
+
+```html
+<body>
+ <div class="off-canvas-wrapper" data-off-canvas-wrapper></div>
+</body>
+```
+
+Inside this wrapper, create an off-canvas menu with the class `.off-canvas` and the attribute `data-off-canvas`. The menu also needs a positioning class, which can be `.position-left` or `.position-right`. Make sure the off-cavnas also has a unique ID so it can be targeted.
Along with the menu, the main content of your page will be housed in its own container with the class `.main-content` and attribute `data-off-canvas`.
```html
<body>
- <div class="off-canvas position-left" id="offCanvas" data-off-canvas data-position="left"></div>
- <div class="main-content" data-off-canvas-content></div>
+ <div class="off-canvas-wrapper" data-off-canvas-wrapper>
+ <div class="off-canvas position-left" id="offCanvas" data-off-canvas data-position="left"></div>
+ <div class="main-content" data-off-canvas-content></div>
+ </div>
</body>
```
```html
<body>
- <div class="off-canvas position-left" id="offCanvas" data-off-canvas></div>
- <div class="off-canvas position-right" id="offCanvas" data-off-canvas></div>
- <div class="main-content" data-off-canvas-content></div>
+ <div class="off-canvas-wrapper" data-off-canvas-wrapper>
+ <div class="off-canvas position-left" id="offCanvas" data-off-canvas></div>
+ <div class="off-canvas position-right" id="offCanvas" data-off-canvas></div>
+ <div class="main-content" data-off-canvas-content></div>
+ </div>
</body>
```
<li><a href="#">Sites</a></li>
</ul>
</div>
-
-<div class="off-canvas position-top" id="offCanvasTop" data-off-canvas data-position="top">
- <button class="close-button" aria-label="Close menu" type="button" data-close>
- <span aria-hidden="true">×</span>
- </button>
- <ul class="vertical menu">
- <li><a href="#">Foundation</a></li>
- <li><a href="#">Dot</a></li>
- <li><a href="#">ZURB</a></li>
- <li><a href="#">Com</a></li>
- <li><a href="#">Slash</a></li>
- <li><a href="#">Sites</a></li>
- </ul>
-</div>
this._setMQChecker();
}
if(!this.options.transitionTime){
- this.options.transitionTime = parseFloat(window.getComputedStyle(document.body).transitionDuration) * 1000;
+ this.options.transitionTime = parseFloat(window.getComputedStyle($('[data-off-canvas-wrapper]')[0]).transitionDuration) * 1000;
}
};
* @event OffCanvas#opened
*/
Foundation.Move(this.options.transitionTime, this.$element, function(){
- $body.addClass('is-off-canvas-open is-open-'+ _this.options.position);
+ $('[data-off-canvas-wrapper]').addClass('is-off-canvas-open is-open-'+ _this.options.position);
_this.$element
.addClass('is-open')
var _this = this;
Foundation.Move(this.options.transitionTime, this.$element, function(){
- $('body').removeClass('is-off-canvas-open is-open-'+_this.options.position);
+ $('[data-off-canvas-wrapper]').removeClass('is-off-canvas-open is-open-'+_this.options.position);
_this.$element.removeClass('is-open');
// Foundation._reflow();
/// Background color of an off-canvas menu.
/// @type Color
-$offcanvas-background: $white;
+$offcanvas-background: $light-gray;
/// Z-index of an off-canvas menu.
/// @type Number
/// Adds baseline styles for off-canvas. This CSS is required to make the other pieces work.
@mixin off-canvas-basics {
// Extra properties needed on <html> and <body> to make off-canvas work
-
html,
body {
height: 100%;
}
+ html {
+ position: relative;
+ overflow: hidden;
+ backface-visibility: hidden;
+ width: 100%;
+ }
+
body {
+ width: 100%;
overflow-x: hidden;
- transition: transform $offcanvas-transition-length $offcanvas-transition-timing;
+ position: relative;
backface-visibility: hidden;
+
@if $maincontent-prevent-scroll == true {
&.is-off-canvas-open {
- overflow-y: hidden;//proposed change to prevent scroll on offcanvas open.
+ overflow-y: hidden;
}
}
}
+ .off-canvas-wrapper {
+ position: relative;
+ width: 100%;
+ transition: transform $offcanvas-transition-length $offcanvas-transition-timing;
+ }
+
// Click-to-exit overlay (generated by JavaScript)
.js-off-canvas-exit {
display: none;
- //chris
- // position: fixed;
position: absolute;
top: 0;
left: 0;
position: absolute;
background: $offcanvas-background;
z-index: $offcanvas-zindex;
+ min-height: 100%;
+ transform: translateX(0px);
}
@mixin off-canvas-position(
background: $body-background;
transition: transform $offcanvas-transition-length $offcanvas-transition-timing;
backface-visibility: hidden;
+ z-index: 1;
@if hasvalue($maincontent-shadow) {
box-shadow: $maincontent-shadow;