From 3469fbfafa5da9015032bcd97423c248b5f03e2f Mon Sep 17 00:00:00 2001 From: Nathan Arthur Date: Wed, 3 Feb 2016 14:02:06 -0600 Subject: [PATCH] Made animateHeight option work when using the fade animation --- src/js/unslider.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/js/unslider.js b/src/js/unslider.js index 22d2774..ce9540e 100755 --- a/src/js/unslider.js +++ b/src/js/unslider.js @@ -497,9 +497,7 @@ // If we want to change the height of the slider // to match the current slide, you can set // {animateHeight: true} - if(self.options.animateHeight) { - self._move(self.$context, {height: self.$slides.eq(to).outerHeight()}, false); - } + self.animateHeight(to); // For infinite sliding we add a dummy slide at the end and start // of each slider to give the appearance of being infinite @@ -550,7 +548,12 @@ // Fade between slides rather than, uh, sliding it - self.animateFade = function(to) { + self.animateFade = function(to) { + // If we want to change the height of the slider + // to match the current slide, you can set + // {animateHeight: true} + self.animateHeight(to); + var $active = self.$slides.eq(to).addClass(self.options.activeClass); // Toggle our classes @@ -558,6 +561,16 @@ self._move($active, {opacity: 1}, false); }; + // Animate height of slider + self.animateHeight = function(to) { + // If we want to change the height of the slider + // to match the current slide, you can set + // {animateHeight: true} + if (self.options.animateHeight) { + self._move(self.$context, {height: self.$slides.eq(to).outerHeight()}, false); + } + }; + self._move = function($el, obj, callback, speed) { if(callback !== false) { callback = function() {