Skip to content

Commit

Permalink
Merge pull request #340 from Narthur/master
Browse files Browse the repository at this point in the history
Make `animation: 'fade' ` and `animateHeight: true` compatible
  • Loading branch information
Visual Idiot committed Mar 5, 2016
2 parents 3cf5982 + 3469fbf commit 9e737da
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.esproj
.DS_Store
.codekit-cache
node_modules
node_modules
.idea/**/*
21 changes: 17 additions & 4 deletions src/js/unslider.js
Original file line number Diff line number Diff line change
Expand Up @@ -507,9 +507,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 @@ -560,14 +558,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 9e737da

Please sign in to comment.