var $html;
var template = `<div class="off-canvas-wrapper">
<div class="off-canvas-wrapper-inner" data-off-canvas-wrapper>
- <div class="off-canvas position-left" id="offCanvas" data-off-canvas>
+ <div class="off-canvas position-left" id="offCanvas" data-off-canvas data-content-scroll="false">
<!-- Close button -->
<button class="close-button" aria-label="Close menu" type="button" data-close>
$html = $(template).appendTo('body');
plugin = new Foundation.OffCanvas($html.find('[data-off-canvas]'), {closeOnClick: true});
- plugin.$exiter.should.be.an('object');
+ plugin.$overlay.should.be.an('object');
- $html.one(Foundation.transitionend($html), function() {
- plugin.$exiter.trigger('click');
+ $html.one('opened.zf.offcanvas', function() {
+ plugin.$overlay.trigger('click');
plugin.$element.should.not.have.class('is-open');
- done();
+ done();
});
plugin.open();
$html = $(template).appendTo('body');
plugin = new Foundation.OffCanvas($html.find('[data-off-canvas]'), {});
- $html.one(Foundation.transitionend($html), function() {
+ //$html.one(Foundation.transitionend($html), function() {
+ $html.one('opened.zf.offcanvas', function() {
plugin.$triggers.should.have.attr('aria-expanded', 'true');
plugin.$element.should.have.attr('aria-hidden', 'false');
done();
$html = $(template).appendTo('body');
plugin = new Foundation.OffCanvas($html.find('[data-off-canvas]'), {});
- $html.one(Foundation.transitionend($html), function() {
- plugin.$element.should.have.class('is-open');
- $html.find('[data-off-canvas-wrapper]').should.have.class('is-off-canvas-open');
- done();
+ $html.one('opened.zf.offcanvas', function() {
+ setTimeout(function() {
+ plugin.$element.should.have.class('is-open');
+ $('body').should.have.class('is-off-canvas-open');
+ done();
+ }, 1);
});
plugin.open();
plugin = new Foundation.OffCanvas($html.find('[data-off-canvas]'), {autoFocus: true});
- $html.one(Foundation.transitionend($html), function() {
- plugin.$element.should.have.attr('tabindex', '-1');
- plugin.$element[0].should.be.equal(document.activeElement);
- done();
- });
-
- plugin.open();
- });
-
- it('sets tabindex attribute to -1 if trapFocus option is true', function(done) {
- $html = $(template).appendTo('body');
- plugin = new Foundation.OffCanvas($html.find('[data-off-canvas]'), {trapFocus: true});
-
- $html.one(Foundation.transitionend($html), function() {
- plugin.$element.should.have.attr('tabindex', '-1');
- done();
+ plugin.$element.one(Foundation.transitionend(plugin.$element),function() {
+ setTimeout(function() {
+ plugin.$element.find('a, button')[0].should.be.equal(document.activeElement);
+ done();
+ }, 1);
});
plugin.open();
+ // fake transitionend for console tests
+ plugin.$element.triggerHandler(Foundation.transitionend(plugin.$element));
});
$html = $(template).appendTo('body');
plugin = new Foundation.OffCanvas($html.find('[data-off-canvas]'), {});
- $html.on('opened.zf.offcanvas', function() {
- $html.one(Foundation.transitionend($html), function() {
- done();
- });
+ $html.one('opened.zf.offcanvas', function() {
+ done();
});
plugin.open();
$html = $(template).appendTo('body');
plugin = new Foundation.OffCanvas($html.find('[data-off-canvas]'), {});
- $html.one(Foundation.transitionend($html), function() {
+ $html.one('opened.zf.offcanvas', function() {
plugin.close();
plugin.$triggers.should.have.attr('aria-expanded', 'false');
$html = $(template).appendTo('body');
plugin = new Foundation.OffCanvas($html.find('[data-off-canvas]'), {});
- $html.one(Foundation.transitionend($html), function() {
- plugin.close();
+ $html.one('opened.zf.offcanvas', function() {
+ setTimeout(function() {
+ plugin.close();
- plugin.$element.should.not.have.class('is-open');
- $html.find('[data-off-canvas-wrapper]').should.not.have.class('is-off-canvas-open');
- done();
+ plugin.$element.should.not.have.class('is-open');
+ $('body').should.not.have.class('is-off-canvas-open');
+ done();
+ }, 1);
});
// Open it first
$html = $(template).appendTo('body');
plugin = new Foundation.OffCanvas($html.find('[data-off-canvas]'), {});
-
- $html.one(Foundation.transitionend($html), function() {
+
+ $html.one('opened.zf.offcanvas', function() {
$html.one('closed.zf.offcanvas', function() {
done();
});
$html = $(template).appendTo('body');
plugin = new Foundation.OffCanvas($html.find('[data-off-canvas]'), {});
- $html.one(Foundation.transitionend($html), function() {
+ $html.one('opened.zf.offcanvas', function() {
plugin.$element.should.have.class('is-open');
done();
});
$html = $(template).appendTo('body');
plugin = new Foundation.OffCanvas($html.find('[data-off-canvas]'), {});
- $html.one(Foundation.transitionend($html), function() {
+ $html.one('opened.zf.offcanvas', function() {
plugin.toggle();
plugin.$element.should.not.have.class('is-open');
});
});
-});
\ No newline at end of file
+});