From: jk Date: Wed, 4 May 2016 20:11:23 +0000 (+0200) Subject: split this._bindHandler for each event X-Git-Tag: v6.2.2-rc1~8^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F8696%2Fhead;p=thirdparty%2Ffoundation%2Ffoundation-sites.git split this._bindHandler for each event --- diff --git a/js/foundation.equalizer.js b/js/foundation.equalizer.js index 910099b19..e28b203e5 100644 --- a/js/foundation.equalizer.js +++ b/js/foundation.equalizer.js @@ -38,7 +38,10 @@ class Equalizer { this.hasNested = this.$element.find('[data-equalizer]').length > 0; this.isNested = this.$element.parentsUntil(document.body, '[data-equalizer]').length > 0; this.isOn = false; - this._bindHandler = this._bindHandlers.bind(this); + this._bindHandler = { + onResizeMeBound: this._onResizeMe.bind(this), + onPostEqualizedBound: this._onPostEqualized.bind(this) + }; var imgs = this.$element.find('img'); var tooSmall; @@ -63,15 +66,26 @@ class Equalizer { */ _pauseEvents() { this.isOn = false; - this.$element.off('.zf.equalizer resizeme.zf.trigger',this._bindHandler); + this.$element.off({ + '.zf.equalizer': this._bindHandler.onPostEqualizedBound, + 'resizeme.zf.trigger': this._bindHandler.onResizeMeBound + }); } - _bindHandlers(e) { - if (e.type === 'resizeme') { - this._reflow(); - }else if (e.type === 'postequalized'){ - if(e.target !== this.$element[0]){ this._reflow(); } - }; + /** + * function to handle $elements resizeme.zf.trigger, with bound this on _bindHandler.onResizeMeBound + * @private + */ + _onResizeMe(e) { + this._reflow(); + } + + /** + * function to handle $elements postequalized.zf.equalizer, with bound this on _bindHandler.onPostEqualizedBound + * @private + */ + _onPostEqualized(e) { + if(e.target !== this.$element[0]){ this._reflow(); } } /** @@ -82,9 +96,9 @@ class Equalizer { var _this = this; this._pauseEvents(); if(this.hasNested){ - this.$element.on('postequalized.zf.equalizer', this._bindHandler); + this.$element.on('postequalized.zf.equalizer', this._bindHandler.onPostEqualizedBound); }else{ - this.$element.on('resizeme.zf.trigger', this._bindHandler); + this.$element.on('resizeme.zf.trigger', this._bindHandler.onResizeMeBound); } this.isOn = true; } diff --git a/test/visual/equalizer/equalizer-events.html b/test/visual/equalizer/equalizer-events.html index 01e919321..48e226080 100644 --- a/test/visual/equalizer/equalizer-events.html +++ b/test/visual/equalizer/equalizer-events.html @@ -9,7 +9,7 @@
-

I Fire preequalized and postequalized on medium-up

+

I Fire preequalized and postequalized on medium-up and also after _pauseEvents