Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #17 from simonratner/proportional-transition-duration

Set transition duration proportionally to the remaining distance
  • Loading branch information...
commit 3a21d67a1955d27018d9827ec8533007cc095aea 2 parents 51f7da3 + c11a19c
Matteo Spinelli authored
Showing with 4 additions and 4 deletions.
  1. +4 −4 src/swipeview.js
8 src/swipeview.js
View
@@ -331,7 +331,7 @@ var SwipeView = (function(){
// Check if we exceeded the snap threshold
if (dist < this.snapThreshold) {
- this.slider.style.webkitTransitionDuration = '300ms';
+ this.slider.style.webkitTransitionDuration = Math.floor(300 * dist / this.snapThreshold) + 'ms';
this.__pos(-this.page * this.pageWidth);
return;
}
@@ -380,9 +380,9 @@ var SwipeView = (function(){
pageFlipIndex = pageFlipIndex - Math.floor(pageFlipIndex / this.options.numberOfPages) * this.options.numberOfPages;
this.masterPages[pageFlip].dataset.upcomingPageIndex = pageFlipIndex; // Index to be loaded in the newly flipped page
- this.slider.style.webkitTransitionDuration = '500ms';
-
newX = -this.page * this.pageWidth;
+
+ this.slider.style.webkitTransitionDuration = Math.floor(500 * Math.abs(this.x - newX) / this.pageWidth) + 'ms';
// Hide the next page if we decided to disable looping
if (!this.options.loop) {
@@ -416,4 +416,4 @@ var SwipeView = (function(){
};
return SwipeView;
-})();
+})();
Please sign in to comment.
Something went wrong with that request. Please try again.