]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Update interchange & test to work within the paradigm of [data-resize] and its 10... 9626/head
authorKevin Ball <kmball11@gmail.com>
Fri, 13 Jan 2017 23:09:37 +0000 (15:09 -0800)
committerKevin Ball <kmball11@gmail.com>
Fri, 13 Jan 2017 23:09:37 +0000 (15:09 -0800)
js/foundation.interchange.js
test/javascript/components/interchange.js

index 47a1890450451c6cb726968c6d67e781eb391982..d625cb4e0214b3797f29b4af2bfe5f5bb6e5cebf 100644 (file)
@@ -52,7 +52,7 @@ class Interchange {
    * @private
    */
   _events() {
-    this.$element.off('resizeme.zf.trigger').on('resizeme.zf.trigger', this._reflow.bind(this));
+    this.$element.off('resizeme.zf.trigger').on('resizeme.zf.trigger', () => {this._reflow();});
   }
 
   /**
index 8186c4eafd8f70fff668a1497d450c696f639c6b..afc8d634d873f2c667d83a9c1a5ca0f3df5d615e 100644 (file)
@@ -12,7 +12,7 @@ describe('Interchange', function() {
     switch (type) {
       case 'image':
       case 'background':
-        return `_build/assets/img/interchange/${size}.jpg`;  
+        return `_build/assets/img/interchange/${size}.jpg`;
       default:
         return `_build/assets/partials/interchange-${size}.html`;
     }
@@ -32,7 +32,7 @@ describe('Interchange', function() {
             [${getPath(type, 'small')}, small],
             [${getPath(type, 'medium')}, medium],
             [${getPath(type, 'large')}, large]
-          ">`;  
+          ">`;
       case 'background':
         return `<div data-interchange="
             [${getPath(type, 'small')}, small],
@@ -87,12 +87,12 @@ describe('Interchange', function() {
       plugin = new Foundation.Interchange($html, {});
 
       var spy = sinon.spy($, 'get');
-      
+
       plugin.replace(getPath('template', 'large'));
 
       sinon.assert.calledWith(spy, getPath('template', 'large'));
 
-      spy.restore();      
+      spy.restore();
     });
 
     it('fires replaced.zf.interchange event', function() {
@@ -103,7 +103,7 @@ describe('Interchange', function() {
       $html.on('replaced.zf.interchange', spy);
 
       plugin.replace(getPath('image', 'large'));
-      
+
       sinon.assert.called(spy);
     });
   });
@@ -170,26 +170,27 @@ describe('Interchange', function() {
     it('calls reflow on viewport size change once', function(done) {
       $html = $(generateTemplate('image')).appendTo('body');
       plugin = new Foundation.Interchange($html, {});
-
+      Foundation.IHearYou();
       let spy = sinon.spy(plugin, '_reflow');
-      
-      $(window).trigger('resize');
 
       setTimeout(function() {
         $(window).trigger('resize');
-      }, 30);
+      }, 1);
 
       setTimeout(function() {
         $(window).trigger('resize');
-      }, 60);
+      }, 5);
 
-      setTimeout(function() { // Wait for third trigger...
+      setTimeout(function() {
         $(window).trigger('resize');
+      }, 10);
+
+      setTimeout(function() { // Wait for third trigger...
         sinon.assert.calledOnce(spy);
         done();
-      }, 60);
+      }, 50);
     });
   });
 
 
-});
\ No newline at end of file
+});