diff --git a/src/js/unslider.js b/src/js/unslider.js index 8cc25b4..964e3ba 100755 --- a/src/js/unslider.js +++ b/src/js/unslider.js @@ -43,7 +43,7 @@ // An easing string to use. If you're using Velocity, use a // Velocity string otherwise you can use jQuery/jQ UI options. easing: 'swing', // [.42, 0, .58, 1], - + // Does it support keyboard arrows? // Can pass either true or false - // or an object with the keycodes, like so: @@ -57,7 +57,7 @@ prev: 37, next: 39 }, - + // Do you want to generate clickable navigation // to skip to each slide? Accepts boolean true/false or // a callback function per item to generate. @@ -100,7 +100,7 @@ swipe: true, // Swipe threshold - // lower float for enabling short swipe - swipeThreshold: 0.2 + swipeThreshold: 0.2 }; // Set defaults @@ -115,7 +115,7 @@ self.$slides = null; self.$nav = null; self.$arrows = []; - + // Set our indexes and totals self.total = 0; self.current = 0; @@ -186,6 +186,9 @@ // Set up the slide widths to animate with // so the box doesn't float over self.calculateSlides = function() { + // update slides before recalculating the total + self.$slides = self.$container.children(self.options.selectors.slides); + self.total = self.$slides.length; // Set the total width @@ -244,7 +247,7 @@ // And add it to our navigation item $nav.children('ol').append('
  • ' + label + '
  • '); }); - + // Keep a copy of the nav everywhere so we can use it self.$nav = $nav.insertAfter(self.$context); @@ -349,7 +352,7 @@ $.each(pos, function(index, item) { self.$slides.push.apply( self.$slides, - + // Exclude all cloned slides and call .first() or .last() // depending on what `item` is. self.$slides.filter(':not(".' + self._ + '-clone")')[item]() @@ -384,7 +387,7 @@ }; // Unset the keyboard navigation - // Remove the handler + // Remove the handler self.destroyKeys = function() { // Remove the event handler $(document).off('keyup' + self.eventSuffix); @@ -405,7 +408,7 @@ return self; }; - + // Despite the name, this doesn't do any animation - since there's // now three different types of animation, we let this method delegate // to the right type, keeping the name for backwards compat. @@ -433,7 +436,7 @@ self.$context.trigger(self._ + '.change', [to, self.$slides.eq(to)]); // Delegate the right method - everything's named consistently - // so we can assume it'll be called "animate" + + // so we can assume it'll be called "animate" + var fn = 'animate' + $._ucfirst(self.options.animation); // Make sure it's a valid animation method, otherwise we'll get @@ -465,7 +468,7 @@ self.prev = function() { return self.animate(self.current - 1, 'prev'); }; - + // Our default animation method, the old-school left-to-right // horizontal animation @@ -644,5 +647,5 @@ return $this.data('unslider', new $.Unslider($this, opts)); }); }; - -})); \ No newline at end of file + +}));