Created
June 5, 2018 06:54
-
-
Save jschaefer-workmatrix/346ec9f1c6fae6e12408b060a5ed0eb1 to your computer and use it in GitHub Desktop.
my solution for https://github.com/kenwheeler/slick/issues/179
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.fn.equalHeightSlickSlider = function() { | |
var | |
$slider = $(this), | |
$slides = $('.slick-slide', $slider), | |
$slideitems = $('> div', $slides), | |
slideCount = $slides.first().find('> div').length, | |
slideHeight = 0 | |
; | |
console.log(slideHeight); | |
$slides.each(function(){ | |
slideHeight = Math.max($(this).outerHeight(), slideHeight); | |
slideCount = Math.max(slideCount, $(this).children().length); | |
}); | |
$slideitems.height(slideHeight / slideCount); | |
return $(this); | |
} | |
var $slider = $('.slick-slider'); | |
var equalizeSliderHeights = function(){ | |
var | |
frequency = 250, | |
timeout = false | |
; | |
return function() { | |
if (timeout) { | |
return; | |
} | |
timeout = setTimeout(function() { | |
timeout = false; | |
}, frequency); | |
$slider.equalHeightSlickSlider(); | |
}; | |
}; | |
$(window).on('DOMContentLoaded load resize', equalizeSliderHeights()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment