From: Kevin Ball Date: Thu, 13 Oct 2016 18:20:30 +0000 (-0700) Subject: Fix off canvas issues with right side & double clicks X-Git-Tag: v6.2.4-rc2~9^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F9253%2Fhead;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Fix off canvas issues with right side & double clicks --- diff --git a/js/foundation.offcanvas.js b/js/foundation.offcanvas.js index 1ab73c8f8..f256a802e 100644 --- a/js/foundation.offcanvas.js +++ b/js/foundation.offcanvas.js @@ -173,16 +173,15 @@ class OffCanvas { * Fires when the off-canvas menu opens. * @event OffCanvas#opened */ - Foundation.Move(this.options.transitionTime, this.$element, function() { - $('[data-off-canvas-wrapper]').addClass('is-off-canvas-open is-open-'+ _this.options.position); - _this.$element - .addClass('is-open') + var $wrapper = $('[data-off-canvas-wrapper]'); + $wrapper.addClass('is-off-canvas-open is-open-'+ _this.options.position); + + _this.$element.addClass('is-open') // if (_this.options.isSticky) { // _this._stick(); // } - }); this.$triggers.attr('aria-expanded', 'true'); this.$element.attr('aria-hidden', 'false') @@ -197,17 +196,21 @@ class OffCanvas { } if (this.options.autoFocus) { - this.$element.attr('tabindex', '-1'); - this.$element.focus(); - - /*this.$element.one(Foundation.transitionend(this.$element), function() { - _this.$element.focus(); - });*/ + $wrapper.one(Foundation.transitionend($wrapper), function() { + if(_this.$element.hasClass('is-open')) { // handle double clicks + _this.$element.attr('tabindex', '-1'); + _this.$element.focus(); + } + }); } if (this.options.trapFocus) { - this.$element.attr('tabindex', '-1'); - this._trapFocus(); + $wrapper.one(Foundation.transitionend($wrapper), function() { + if(_this.$element.hasClass('is-open')) { // handle double clicks + _this.$element.attr('tabindex', '-1'); + _this.trapFocus(); + } + }); } }