Skip to content

Commit

Permalink
Made animateHeight option work when using the fade animation
Browse files Browse the repository at this point in the history
  • Loading branch information
narthur committed Feb 3, 2016
1 parent b614da0 commit 3469fbf
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/js/unslider.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -550,14 +548,29 @@


// 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
self._move($active.siblings().removeClass(self.options.activeClass), {opacity: 0});
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() {
Expand Down

0 comments on commit 3469fbf

Please sign in to comment.