Use blocked scoped variables

In addition to using const and let, this also upgrades our linter config and removes lint (mostly whitespace).
This commit is contained in:
Tim Schaub
2018-01-11 23:32:36 -07:00
parent 0bf2b04dee
commit ad62739a6e
684 changed files with 18120 additions and 18184 deletions

View File

@@ -14,7 +14,7 @@
* @struct
* @api
*/
var Kinetic = function(decay, minVelocity, delay) {
const Kinetic = function(decay, minVelocity, delay) {
/**
* @private
@@ -82,8 +82,8 @@ Kinetic.prototype.end = function() {
// in the array)
return false;
}
var delay = Date.now() - this.delay_;
var lastIndex = this.points_.length - 3;
const delay = Date.now() - this.delay_;
const lastIndex = this.points_.length - 3;
if (this.points_[lastIndex + 2] < delay) {
// the last tracked point is too old, which means that the user stopped
// panning before releasing the map
@@ -91,12 +91,12 @@ Kinetic.prototype.end = function() {
}
// get the first point which still falls into the delay time
var firstIndex = lastIndex - 3;
let firstIndex = lastIndex - 3;
while (firstIndex > 0 && this.points_[firstIndex + 2] > delay) {
firstIndex -= 3;
}
var duration = this.points_[lastIndex + 2] - this.points_[firstIndex + 2];
const 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
@@ -104,8 +104,8 @@ Kinetic.prototype.end = function() {
return false;
}
var dx = this.points_[lastIndex] - this.points_[firstIndex];
var dy = this.points_[lastIndex + 1] - this.points_[firstIndex + 1];
const dx = this.points_[lastIndex] - this.points_[firstIndex];
const dy = this.points_[lastIndex + 1] - this.points_[firstIndex + 1];
this.angle_ = Math.atan2(dy, dx);
this.initialVelocity_ = Math.sqrt(dx * dx + dy * dy) / duration;
return this.initialVelocity_ > this.minVelocity_;