Skip to content

Commit

Permalink
Fixed elastic swipers, so that they don't have any remaining space wh…
Browse files Browse the repository at this point in the history
…en paging to the last slide.
  • Loading branch information
ivancamilov committed Aug 29, 2014
1 parent aa9ffae commit 4e956e8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions swipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,10 @@ function Swipe(container, options) {
// do nothing if already on requested slide
if (index == to) return;

if(elastic && (containerWidth - ((slides.length * width)-(width*(to-1))) > 0)) {
index = to;
return;
// last page logic
var remainingDistance;
if(elastic && (containerWidth - ((slides.length * width)-(width*(to))) > 0)) {
remainingDistance = (containerWidth - ((slides.length * width)-(width*(to))) > 0) - (containerWidth - ((slides.length * width)-(width*(to-1))));
}

if (browser.transitions) {
Expand Down Expand Up @@ -204,7 +205,10 @@ function Swipe(container, options) {
to = circle(to);

if(orientation == 'horizontal')
animate(index * -width, to * -width, slideSpeed || speed);
if(remainingDistance)
animate(index * -width, (index * -width) - remainingDistance, slideSpeed || speed);
else
animate(index * -width, to * -width, slideSpeed || speed);
else if(orientation == 'vertical')
animate(index * -height, to * -height, slideSpeed || speed);
//no fallback for a circular continuous if the browser does not accept transitions
Expand Down

0 comments on commit 4e956e8

Please sign in to comment.