From: jk Date: Thu, 28 Apr 2016 21:53:54 +0000 (+0200) Subject: possible fix for #8690 X-Git-Tag: v6.2.2-rc1~8^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7b79c559961990cf45f3631ba75bf5ef0e325b11;p=thirdparty%2Ffoundation%2Ffoundation-sites.git possible fix for #8690 assign a this var with a function.bind(this) to off only the function on _pauseEvents() --- diff --git a/js/foundation.equalizer.js b/js/foundation.equalizer.js index f20f279f2..910099b19 100644 --- a/js/foundation.equalizer.js +++ b/js/foundation.equalizer.js @@ -38,6 +38,7 @@ 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); var imgs = this.$element.find('img'); var tooSmall; @@ -62,7 +63,15 @@ class Equalizer { */ _pauseEvents() { this.isOn = false; - this.$element.off('.zf.equalizer resizeme.zf.trigger'); + this.$element.off('.zf.equalizer resizeme.zf.trigger',this._bindHandler); + } + + _bindHandlers(e) { + if (e.type === 'resizeme') { + this._reflow(); + }else if (e.type === 'postequalized'){ + if(e.target !== this.$element[0]){ this._reflow(); } + }; } /** @@ -73,11 +82,9 @@ class Equalizer { var _this = this; this._pauseEvents(); if(this.hasNested){ - this.$element.on('postequalized.zf.equalizer', function(e){ - if(e.target !== _this.$element[0]){ _this._reflow(); } - }); + this.$element.on('postequalized.zf.equalizer', this._bindHandler); }else{ - this.$element.on('resizeme.zf.trigger', this._reflow.bind(this)); + this.$element.on('resizeme.zf.trigger', this._bindHandler); } this.isOn = true; } diff --git a/test/visual/equalizer/equalizer-events.html b/test/visual/equalizer/equalizer-events.html new file mode 100644 index 000000000..01e919321 --- /dev/null +++ b/test/visual/equalizer/equalizer-events.html @@ -0,0 +1,88 @@ + + + + + + + Foundation for Sites Testing + + + +
+

I Fire preequalized and postequalized on medium-up

+
+
+
+
+
Test
+
+
+
+
+
Test
+
+
+
+
+
Test
+
+
+
+
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fuga officia iste ut distinctio magni accusantium, optio ipsa at cupiditate sequi!
+
+
+
+
+

I Fire preequalized, preequalizedrow, postequalizedrow, postequalized, resizeme

+
+
+
+
+
Test
+
+
+
+
+
Test
+
+
+
+
+
Test
+
+
+
+
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Libero dolore inventore quibusdam deleniti a ipsa laborum, illo, soluta quas velit?
+
+
+
+ + + + + +