Skip to content
Browse files

set transition duration proportionally to the remaining distance

  • Loading branch information...
1 parent 51f7da3 commit c11a19ceb0e558c05ecbd03acb6827e495c18887 @simonratner simonratner committed Mar 21, 2012
Showing with 4 additions and 4 deletions.
  1. +4 −4 src/swipeview.js
View
8 src/swipeview.js
@@ -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;
-})();
+})();

0 comments on commit c11a19c

Please sign in to comment.
Something went wrong with that request. Please try again.