diff --git a/example/demo.js b/example/demo.js
index 20f1c55..9c7de41 100644
--- a/example/demo.js
+++ b/example/demo.js
@@ -22,6 +22,13 @@ if (!$('.demo').length) return;
});
})();
+(function distance() {
+ Flipsnap('#demo-rtl .flipsnap', {
+ distance: 230,
+ isRTL: true
+ });
+})();
+
(function maxPoint() {
Flipsnap('#demo-maxPoint .flipsnap', {
distance: 160, // 80px * 2
diff --git a/example/index.html b/example/index.html
index 82b27d0..8ff4142 100644
--- a/example/index.html
+++ b/example/index.html
@@ -60,6 +60,19 @@
distance
+
+
maxPoint
diff --git a/example/style.css b/example/style.css
index e6816e5..ff6d8fa 100644
--- a/example/style.css
+++ b/example/style.css
@@ -18,6 +18,17 @@ h1, h2, h3 {
padding: 30px 0;
-webkit-transform: translateZ(0); }
+.flex {
+ display: -webkit-box;
+ display: -webkit-flex;
+ display: flex;
+}
+.flex > * {
+ -webkit-box-flex: 1;
+ -webkit-flex: 1;
+ flex: 1;
+}
+
.flipsnap {
width: 1195px;
/* 230px(item) * 5 + 45px(padding) */
diff --git a/flipsnap.js b/flipsnap.js
index 1df35e6..3bd290b 100644
--- a/flipsnap.js
+++ b/flipsnap.js
@@ -110,6 +110,7 @@ Flipsnap.prototype.init = function(element, opts) {
opts = opts || {};
self.distance = opts.distance;
self.maxPoint = opts.maxPoint;
+ self.isRTL = opts.isRTL || document.documentElement.getAttribute('dir') === 'rtl';
self.disableTouch = (opts.disableTouch === undefined) ? false : opts.disableTouch;
self.disable3d = (opts.disable3d === undefined) ? false : opts.disable3d;
self.transitionDuration = (opts.transitionDuration === undefined) ? '350ms' : opts.transitionDuration + 'ms';
@@ -204,7 +205,9 @@ Flipsnap.prototype.refresh = function() {
else {
self._distance = self.distance;
}
-
+ if (self.isRTL) {
+ self._distance = -self._distance;
+ }
// setting maxX
self._maxX = -self._distance * self._maxPoint;
@@ -404,6 +407,10 @@ Flipsnap.prototype._touchEnd = function(event, type) {
}
var newPoint = -self.currentX / self._distance;
+
+ if (self.isRTL) {
+ self.directionX = -self.directionX;
+ }
newPoint =
(self.directionX > 0) ? Math.ceil(newPoint) :
(self.directionX < 0) ? Math.floor(newPoint) :