Skip to content

Commit

Permalink
added carousel resize height to fullWidth with images
Browse files Browse the repository at this point in the history
  • Loading branch information
acburst committed Jul 6, 2017
1 parent cdbb8bb commit 16513d5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
18 changes: 11 additions & 7 deletions js/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@


// Options
var setCarouselHeight = function() {
var firstImage = view.find('.carousel-item img').first();
var setCarouselHeight = function(imageOnly) {
var firstImage = view.find('.carousel-item.active img').first();
if (firstImage.length) {
if (firstImage.prop('complete')) {
view.css('height', firstImage.height());
Expand All @@ -44,8 +44,8 @@
view.css('height', $(this).height());
});
}
} else {
var imageHeight = view.find('.carousel-item').first().height();
} else if (!imageOnly) {
var imageHeight = view.find('.carousel-item.active').first().height();
view.css('height', imageHeight);
}
};
Expand Down Expand Up @@ -445,17 +445,21 @@
});


$(window).off('resize.carousel-'+uniqueNamespace).on('resize.carousel-'+uniqueNamespace, function() {
var throttledResize = Materialize.throttle(function() {
if (options.fullWidth) {
item_width = view.find('.carousel-item').first().innerWidth();
item_height = view.find('.carousel-item').first().innerHeight();
var imageHeight = view.find('.carousel-item.active').height();
dim = item_width * 2 + options.padding;
offset = center * 2 * item_width;
target = offset;
setCarouselHeight(true);
} else {
scroll();
}
});
}, 200);
$(window)
.off('resize.carousel-'+uniqueNamespace)
.on('resize.carousel-'+uniqueNamespace, throttledResize);

setupEvents();
scroll(offset);
Expand Down
1 change: 0 additions & 1 deletion sass/components/_carousel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
&.carousel-slider {
top: 0;
left: 0;
height: 0;

.carousel-fixed-item {
&.with-indicators {
Expand Down

0 comments on commit 16513d5

Please sign in to comment.