From fe1cc1a70eb8a78bfcc1dd1dd9dc4659a6ac93a7 Mon Sep 17 00:00:00 2001 From: Kevin Ball Date: Thu, 13 Oct 2016 11:20:30 -0700 Subject: [PATCH] Fix off canvas issues with right side & double clicks --- js/foundation.offcanvas.js | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) 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(); + } + }); } } -- 2.47.2