@@ -306,33 +306,41 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach
306306 }
307307
308308 function getCarouselHeight ( slideNum ) {
309- var slides = carousel . children ( ) ;
310- if ( slides . length === 0 ) {
311- containerHeight = carousel [ 0 ] . getBoundingClientRect ( ) . height ;
312- } else {
313- containerHeight = slides [ slideNum ] . getBoundingClientRect ( ) . height ;
309+ if ( slideNum !== undefined ) {
310+ var slides = carousel . children ( ) ;
311+ for ( var i = slides . length - 1 ; i >= 0 ; i -- ) {
312+ if ( i != slideNum ) {
313+ slides [ i ] . style . height = "0" ;
314+ }
315+ else {
316+ slides [ i ] . style . height = "100%" ;
317+ }
318+ }
319+ if ( slides . length === 0 ) {
320+ containerHeight = carousel [ 0 ] . getBoundingClientRect ( ) . height ;
321+ } else {
322+ containerHeight = slides [ slideNum ] . getBoundingClientRect ( ) . height ;
323+ }
324+ return containerHeight ;
314325 }
315- return containerHeight ;
316326 }
317327
318328 function updateContainerHeight ( slideNum ) {
319329 // force the carousel container height to match the first or current slide height
320330 container . css ( 'height' , '100%' ) ;
321- var height = getCarouselHeight ( slideNum ) ;
322- if ( height ) {
323- container . css ( 'height' , height + 'px' ) ;
324- }
331+ getCarouselHeight ( slideNum ) ;
332+ // if (height) {
333+ // container.css('height', height + 'px');
334+ // }
325335 }
326336
327337 function getCarouselWidth ( ) {
328- // container.css('width', 'auto');
329338 var slides = carousel . children ( ) ;
330339 if ( slides . length === 0 ) {
331340 containerWidth = carousel [ 0 ] . getBoundingClientRect ( ) . width ;
332341 } else {
333342 containerWidth = slides [ 0 ] . getBoundingClientRect ( ) . width ;
334343 }
335- // console.log('getCarouselWidth', containerWidth);
336344 return containerWidth ;
337345 }
338346
@@ -407,6 +415,7 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach
407415 }
408416
409417 function goToSlide ( i , animate ) {
418+ getCarouselHeight ( i ) ;
410419 if ( isNaN ( i ) ) {
411420 i = scope . carouselIndex ;
412421 }
0 commit comments