Fixed infinity problem in scroll view

I guess you can't divide by zero still.
This commit is contained in:
Max Lynch
2013-10-30 11:14:24 -05:00
parent 83a00fa301
commit 979fe8fb7b
7 changed files with 1024 additions and 799 deletions

View File

@ -122,6 +122,8 @@
_scrollTo: function(x, y, time, easing) {
var _this = this;
time = time || 0;
var start = Date.now();
easing = easing || 'cubic-bezier(0.1, 0.57, 0.1, 1)';
@ -150,6 +152,10 @@
time = 0;
}
if(time == Infinity) {
debugger;
}
var dx = ox - x;
var dy = oy - y;
@ -336,6 +342,13 @@
destination = current + ( speed * speed ) / ( 2 * deceleration ) * ( distance < 0 ? -1 : 1 );
duration = speed / deceleration;
if(speed === 0) {
return {
destination: current,
duration: 0
};
}
// Check if the final destination needs to be rubber banded
if ( destination < lowerMargin ) {
// We have dragged too far down, snap back to the maximum
@ -635,6 +648,9 @@
});
},
/**
* Trigger a done scrolling event.
*/
_doneScrolling: function() {
this.didStopScrolling && this.didStopScrolling({
target: this.el,