From: Daniel Ruf Date: Thu, 15 Feb 2018 08:21:57 +0000 (+0100) Subject: fire opened.zf.offcanvas after adding the classes to prevent some race conditions X-Git-Tag: v6.6.0~3^2~295^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=58ca2385e966dc5fcd47f41b32b79fed62f2daa3;p=thirdparty%2Ffoundation%2Ffoundation-sites.git fire opened.zf.offcanvas after adding the classes to prevent some race conditions --- diff --git a/js/foundation.offcanvas.js b/js/foundation.offcanvas.js index 995bf91d4..b335cb0cb 100644 --- a/js/foundation.offcanvas.js +++ b/js/foundation.offcanvas.js @@ -301,15 +301,11 @@ class OffCanvas extends Plugin { this.$element.siblings('[data-off-canvas-content]').css('transition-duration', ''); } - /** - * Fires when the off-canvas menu opens. - * @event OffCanvas#opened - */ this.$element.addClass('is-open').removeClass('is-closed'); - this.$triggers.attr('aria-expanded', 'true'); - this.$element.attr('aria-hidden', 'false') - .trigger('opened.zf.offcanvas'); + this.$element.attr('aria-hidden', 'false'); + + this.$content.addClass('is-open-' + this.position); @@ -328,6 +324,12 @@ class OffCanvas extends Plugin { this.$overlay.addClass('is-closable'); } + /** + * Fires when the off-canvas menu opens. + * @event OffCanvas#opened + */ + this.$element.trigger('opened.zf.offcanvas'); + if (this.options.autoFocus === true) { this.$element.one(transitionend(this.$element), function() { if (!_this.$element.hasClass('is-open')) { diff --git a/test/javascript/components/offcanvas.js b/test/javascript/components/offcanvas.js index 7938dbaf1..d5cace800 100644 --- a/test/javascript/components/offcanvas.js +++ b/test/javascript/components/offcanvas.js @@ -104,7 +104,7 @@ describe('Off Canvas', function() { plugin.$element.should.have.class('is-open'); $('body').should.have.class('is-off-canvas-open'); done(); - }, 30); + }, 1); }); plugin.open(); @@ -252,7 +252,7 @@ describe('Off Canvas', function() { plugin.toggle(); }); }); - + describe('keyboard events', function() { it('closes Off Canvas on ESCAPE', function(done) { $html = $(template).appendTo('body');