Merge pull request #6902 from ahocevar/fix-kinetic
Require minimum duration for kinetic animation
This commit is contained in:
@@ -94,7 +94,15 @@ ol.Kinetic.prototype.end = function() {
|
|||||||
while (firstIndex > 0 && this.points_[firstIndex + 2] > delay) {
|
while (firstIndex > 0 && this.points_[firstIndex + 2] > delay) {
|
||||||
firstIndex -= 3;
|
firstIndex -= 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
var duration = this.points_[lastIndex + 2] - this.points_[firstIndex + 2];
|
var duration = this.points_[lastIndex + 2] - this.points_[firstIndex + 2];
|
||||||
|
// we don't want a duration of 0 (divide by zero)
|
||||||
|
// we also make sure the user panned for a duration of at least one frame
|
||||||
|
// (1/60s) to compute sane displacement values
|
||||||
|
if (duration < 1000 / 60) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var dx = this.points_[lastIndex] - this.points_[firstIndex];
|
var dx = this.points_[lastIndex] - this.points_[firstIndex];
|
||||||
var dy = this.points_[lastIndex + 1] - this.points_[firstIndex + 1];
|
var dy = this.points_[lastIndex + 1] - this.points_[firstIndex + 1];
|
||||||
this.angle_ = Math.atan2(dy, dx);
|
this.angle_ = Math.atan2(dy, dx);
|
||||||
|
|||||||
Reference in New Issue
Block a user