lazyload-srcset.js 873 B

1234567891011121314151617181920212223242526272829
  1. QUnit.test( 'lazyload srcset', function( assert ) {
  2. 'use strict';
  3. var done = assert.async();
  4. var gallery = document.querySelector('#lazyload-srcset');
  5. var flkty = new Flickity( gallery, {
  6. lazyLoad: 1
  7. });
  8. var loadCount = 0;
  9. flkty.on( 'lazyLoad', function( event, cellElem ) {
  10. loadCount++;
  11. assert.equal( event.type, 'load', 'event.type == load' );
  12. assert.ok( event.target.complete, 'img ' + loadCount + ' is complete' );
  13. assert.ok( cellElem, 'cellElement argument there' );
  14. var srcset = event.target.getAttribute('srcset');
  15. assert.ok( srcset, 'srcset attribute set');
  16. var lazyAttr = event.target.getAttribute('data-flickity-lazyload-srcset');
  17. assert.ok( !lazyAttr, 'data-flickity-lazyload attribute removed' );
  18. // after first 2 have loaded, select 7th cell
  19. if ( loadCount == 2 ) {
  20. done();
  21. }
  22. });
  23. });