From 4ca19c24bad0fc6e174b11d7a2cc4298b4d86535 Mon Sep 17 00:00:00 2001 From: baloneysandwiches Date: Wed, 4 Mar 2015 10:36:32 -0800 Subject: [PATCH] throttle recalc of sentinel on slide add/remove I had trouble with autoheight not working correctly when large batches of slides are added. It was tough to reproduce consistently, but I think I've tracked it down to this. If twenty slides are added all at once, initAutoHeight() should be throttled to only run once. --- src/jquery.cycle2.autoheight.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jquery.cycle2.autoheight.js b/src/jquery.cycle2.autoheight.js index f7615a8f..9a5a18ca 100644 --- a/src/jquery.cycle2.autoheight.js +++ b/src/jquery.cycle2.autoheight.js @@ -18,7 +18,6 @@ $(document).on( 'cycle-initialized', function( e, opts ) { return; // bind events - opts.container.on( 'cycle-slide-added cycle-slide-removed', initAutoHeight ); opts.container.on( 'cycle-destroyed', onDestroy ); if ( autoHeight == 'container' ) { @@ -40,6 +39,7 @@ $(document).on( 'cycle-initialized', function( e, opts ) { resizeThrottle = setTimeout( onResize, 50 ); }; + opts.container.on( 'cycle-slide-added cycle-slide-removed', opts._autoHeightOnResize ); $(window).on( 'resize orientationchange', opts._autoHeightOnResize ); }