contain.js 810 B

123456789101112131415161718192021
  1. QUnit.test( 'contain', function( assert ) {
  2. 'use strict';
  3. var flkty = new Flickity( '#contain', {
  4. contain: true
  5. });
  6. assert.equal( Math.round( flkty.x + flkty.cursorPosition ), 0, 'selected at 0, position left edge' );
  7. flkty.select( 1 );
  8. flkty.positionSliderAtSelected();
  9. assert.equal( Math.round( flkty.x + flkty.cursorPosition ), 0, 'selected at 1, position left edge' );
  10. flkty.select( 4 );
  11. flkty.positionSliderAtSelected();
  12. var endLimit = flkty.slideableWidth - flkty.size.innerWidth * ( 1 - flkty.cellAlign );
  13. assert.equal( Math.round( -endLimit ), Math.round( flkty.x ), 'selected at 4, position right edge' );
  14. flkty.select( 5 );
  15. flkty.positionSliderAtSelected();
  16. assert.equal( Math.round( -endLimit ), Math.round( flkty.x ), 'selected at 5, position right edge' );
  17. });