Skip to content

Commit

Permalink
Merge pull request #341 from closingtag/master
Browse files Browse the repository at this point in the history
Correct swiping behavior - #321
  • Loading branch information
Visual Idiot committed Feb 5, 2016
2 parents 2626413 + 95f5de0 commit 3cf5982
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/js/unslider-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 14 additions & 4 deletions src/js/unslider.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@
// Have swipe support?
// You can set this here with a boolean and always use
// initSwipe/destroySwipe later on.
swipe: true
swipe: true,
// Swipe threshold -
// lower float for enabling short swipe
swipeThreshold: 0.2
};

// Set defaults
Expand Down Expand Up @@ -317,10 +320,17 @@
},

moveend: function(e) {

if((Math.abs(e.distX) / width) < $.event.special.swipe.settings.threshold) {
// Check if swiped distance is greater than threshold.
// If yes slide to next/prev slide. If not animate to
// starting point.

self[ e.distX < 0 ? 'next' : 'prev' ]();
if((Math.abs(e.distX) / width) > self.options.swipeThreshold) {

self[e.distX < 0 ? 'next' : 'prev']();
}
else {

self.$container.animate({left: -(100 * self.current) + '%' }, self.options.speed / 2 );
}
}
});
Expand Down

0 comments on commit 3cf5982

Please sign in to comment.