Created
May 16, 2018 09:50
-
-
Save nikunjkotecha/d812ed1c7cc31f8e088915a89bb24a74 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/owl.carousel.js b/owl.carousel.js | |
index 4d37ffb9ca..3c1d6cfc92 100755 | |
--- a/owl.carousel.js | |
+++ b/owl.carousel.js | |
@@ -868,7 +869,22 @@ | |
if (delta.x !== 0 && this.is('dragging') || !this.is('valid')) { | |
this.speed(this.settings.dragEndSpeed || this.settings.smartSpeed); | |
- this.current(this.closest(stage.x, delta.x !== 0 ? direction : this._drag.direction)); | |
+ | |
+ var currentIndex = this.current(); | |
+ var nextIndex = this.closest(stage.x, delta.x !== 0 ? direction : this._drag.direction); | |
+ | |
+ var slideBy = (this.settings.dragSlideBy === 'page') | |
+ ? this.settings.items | |
+ : this.settings.dragSlideBy; | |
+ | |
+ var indexDiff = nextIndex - currentIndex; | |
+ var mod = (Math.abs(indexDiff) % slideBy); | |
+ | |
+ if (mod > 0) { | |
+ nextIndex = (indexDiff > 0) ? (nextIndex + mod) : (nextIndex - mod); | |
+ } | |
+ | |
+ this.current(nextIndex); | |
this.invalidate('position'); | |
this.update(); | |
@@ -2977,6 +2993,7 @@ | |
'owl-next' | |
], | |
slideBy: 1, | |
+ dragSlideBy: 1, | |
dotClass: 'owl-dot', | |
dotsClass: 'owl-dots', | |
dots: true, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment