Get rid of binarySelect to find the first point.
This commit is contained in:
@@ -90,12 +90,14 @@ ol.Kinetic.prototype.update = function(browserEvent) {
|
|||||||
*/
|
*/
|
||||||
ol.Kinetic.prototype.end = function() {
|
ol.Kinetic.prototype.end = function() {
|
||||||
var now = goog.now();
|
var now = goog.now();
|
||||||
var index = Math.abs(goog.array.binarySelect(this.points_, function(elt) {
|
var lastIndex = this.points_.length - 1;
|
||||||
return elt.t < now - this.delay_;
|
var firstIndex = lastIndex - 1;
|
||||||
}, this));
|
while (firstIndex >= 0 && this.points_[firstIndex].t > now - this.delay_) {
|
||||||
if (index < this.points_.length - 1) {
|
firstIndex--;
|
||||||
var first = this.points_[index];
|
}
|
||||||
var last = this.points_[this.points_.length - 1];
|
if (firstIndex >= 0) {
|
||||||
|
var first = this.points_[firstIndex];
|
||||||
|
var last = this.points_[lastIndex];
|
||||||
var dx = last.x - first.x;
|
var dx = last.x - first.x;
|
||||||
var dy = last.y - first.y;
|
var dy = last.y - first.y;
|
||||||
this.angle_ = Math.atan2(dy, dx);
|
this.angle_ = Math.atan2(dy, dx);
|
||||||
|
|||||||
Reference in New Issue
Block a user