From 113d901ac78152fb32d4dcab07df9421028635bc Mon Sep 17 00:00:00 2001 From: SassNinja Date: Mon, 17 Jul 2017 22:42:46 +0200 Subject: [PATCH] Work over _addContentClasses() and _removeContentClasses() so classes get toggled correctly when using reveal feature Since several revealed off-canvas elements may share the same content container, each element doesn't toggle all has-reveal-x classes anymore but only its own. There's now a condition to limit the toggle of has-transition-x & has-position-x classes to cases where no reveal is included. --- js/foundation.offcanvas.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/js/foundation.offcanvas.js b/js/foundation.offcanvas.js index fa2dd30a5..9fbb0bc03 100644 --- a/js/foundation.offcanvas.js +++ b/js/foundation.offcanvas.js @@ -175,12 +175,14 @@ class OffCanvas extends Plugin { /** * Removes the CSS transition/position classes of the off-canvas content container. * Removing the classes is important when another off-canvas gets opened that uses the same content container. + * @param {Boolean} hasReveal - true if related off-canvas element is revealed. * @private */ _removeContentClasses(hasReveal) { - this.$content.removeClass(this.contentClasses.base.join(' ')); - if (hasReveal === true) { - this.$content.removeClass(this.contentClasses.reveal.join(' ')); + if (typeof hasReveal !== 'boolean') { + this.$content.removeClass(this.contentClasses.base.join(' ')); + } else if (hasReveal === false) { + this.$content.removeClass(`has-reveal-${this.position}`); } } @@ -192,8 +194,9 @@ class OffCanvas extends Plugin { */ _addContentClasses(hasReveal) { this._removeContentClasses(hasReveal); - this.$content.addClass(`has-transition-${this.options.transition} has-position-${this.position}`); - if (hasReveal === true) { + if (typeof hasReveal !== 'boolean') { + this.$content.addClass(`has-transition-${this.options.transition} has-position-${this.position}`); + } else if (hasReveal === true) { this.$content.addClass(`has-reveal-${this.position}`); } } -- 2.47.2