From 441136df6ad316c7ab3862648274918a3a8f7a4d Mon Sep 17 00:00:00 2001 From: David DeSandro Date: Wed, 30 Mar 2016 14:57:51 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20arrange=20complete=20stagger?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/unit/arrange-complete.js | 60 ++++++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 4 deletions(-) diff --git a/test/unit/arrange-complete.js b/test/unit/arrange-complete.js index 3cdf5b0..6788cfb 100644 --- a/test/unit/arrange-complete.js +++ b/test/unit/arrange-complete.js @@ -40,10 +40,19 @@ QUnit.test( 'arrangeComplete', function( assert ) { }); }, function() { - iso.once( 'arrangeComplete', function() { - assert.ok( true, 'after layout mid-way thru transition' ); - next(); - }); + var ticks = 0; + function onArrangeComplete() { + ticks++; + if ( ticks == 2) { + assert.ok( true, 'after layout mid-way thru transition' ); + iso.off( 'arrangeComplete', onArrangeComplete ); + next(); + } else if ( ticks > 2 ) { + assert.ok( false, 'more ticks happened' ); + } + } + + iso.on( 'arrangeComplete', onArrangeComplete ); iso.arrange({ filter: '.a2', @@ -55,6 +64,49 @@ QUnit.test( 'arrangeComplete', function( assert ) { filter: '.b2' }); }, 300 ); + }, + // stagger + function() { + iso.once( 'arrangeComplete', function() { + assert.ok( true, 'arrangeComplete with stagger' ); + next(); + }); + + iso.arrange({ + stagger: 100, + sortBy: 'random', + filter: '*', + transitionDuration: '0.4s' + }); + }, + // stagger, triggered mid-transition + function() { + var ticks = 0; + function onArrangeComplete() { + ticks++; + if ( ticks == 2) { + assert.ok( true, 'after layout mid-way thru transition, with stagger' ); + iso.off( 'arrangeComplete', onArrangeComplete ); + iso.options.stagger = 0; + next(); + } else if ( ticks > 2 ) { + assert.ok( false, 'more ticks happened' ); + } + } + + iso.on( 'arrangeComplete', onArrangeComplete ); + + iso.arrange({ + stagger: 100, + sortBy: 'random', + transitionDuration: '0.4s' + }); + + setTimeout( function() { + iso.arrange({ + filter: '.a1' + }); + }, 250 ); } ];