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:
@@ -18,7 +18,7 @@ import RotationConstraint from '../RotationConstraint.js';
|
||||
* @param {olx.interaction.PinchRotateOptions=} opt_options Options.
|
||||
* @api
|
||||
*/
|
||||
var PinchRotate = function(opt_options) {
|
||||
const PinchRotate = function(opt_options) {
|
||||
|
||||
PointerInteraction.call(this, {
|
||||
handleDownEvent: PinchRotate.handleDownEvent_,
|
||||
@@ -26,7 +26,7 @@ var PinchRotate = function(opt_options) {
|
||||
handleUpEvent: PinchRotate.handleUpEvent_
|
||||
});
|
||||
|
||||
var options = opt_options || {};
|
||||
const options = opt_options || {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -75,18 +75,18 @@ inherits(PinchRotate, PointerInteraction);
|
||||
* @private
|
||||
*/
|
||||
PinchRotate.handleDragEvent_ = function(mapBrowserEvent) {
|
||||
var rotationDelta = 0.0;
|
||||
let rotationDelta = 0.0;
|
||||
|
||||
var touch0 = this.targetPointers[0];
|
||||
var touch1 = this.targetPointers[1];
|
||||
const touch0 = this.targetPointers[0];
|
||||
const touch1 = this.targetPointers[1];
|
||||
|
||||
// angle between touches
|
||||
var angle = Math.atan2(
|
||||
touch1.clientY - touch0.clientY,
|
||||
touch1.clientX - touch0.clientX);
|
||||
const angle = Math.atan2(
|
||||
touch1.clientY - touch0.clientY,
|
||||
touch1.clientX - touch0.clientX);
|
||||
|
||||
if (this.lastAngle_ !== undefined) {
|
||||
var delta = angle - this.lastAngle_;
|
||||
const delta = angle - this.lastAngle_;
|
||||
this.rotationDelta_ += delta;
|
||||
if (!this.rotating_ &&
|
||||
Math.abs(this.rotationDelta_) > this.threshold_) {
|
||||
@@ -96,8 +96,8 @@ PinchRotate.handleDragEvent_ = function(mapBrowserEvent) {
|
||||
}
|
||||
this.lastAngle_ = angle;
|
||||
|
||||
var map = mapBrowserEvent.map;
|
||||
var view = map.getView();
|
||||
const map = mapBrowserEvent.map;
|
||||
const view = map.getView();
|
||||
if (view.getConstraints().rotation === RotationConstraint.disable) {
|
||||
return;
|
||||
}
|
||||
@@ -105,18 +105,18 @@ PinchRotate.handleDragEvent_ = function(mapBrowserEvent) {
|
||||
// rotate anchor point.
|
||||
// FIXME: should be the intersection point between the lines:
|
||||
// touch0,touch1 and previousTouch0,previousTouch1
|
||||
var viewportPosition = map.getViewport().getBoundingClientRect();
|
||||
var centroid = PointerInteraction.centroid(this.targetPointers);
|
||||
const viewportPosition = map.getViewport().getBoundingClientRect();
|
||||
const centroid = PointerInteraction.centroid(this.targetPointers);
|
||||
centroid[0] -= viewportPosition.left;
|
||||
centroid[1] -= viewportPosition.top;
|
||||
this.anchor_ = map.getCoordinateFromPixel(centroid);
|
||||
|
||||
// rotate
|
||||
if (this.rotating_) {
|
||||
var rotation = view.getRotation();
|
||||
const rotation = view.getRotation();
|
||||
map.render();
|
||||
Interaction.rotateWithoutConstraints(view,
|
||||
rotation + rotationDelta, this.anchor_);
|
||||
rotation + rotationDelta, this.anchor_);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -129,13 +129,13 @@ PinchRotate.handleDragEvent_ = function(mapBrowserEvent) {
|
||||
*/
|
||||
PinchRotate.handleUpEvent_ = function(mapBrowserEvent) {
|
||||
if (this.targetPointers.length < 2) {
|
||||
var map = mapBrowserEvent.map;
|
||||
var view = map.getView();
|
||||
const map = mapBrowserEvent.map;
|
||||
const view = map.getView();
|
||||
view.setHint(ViewHint.INTERACTING, -1);
|
||||
if (this.rotating_) {
|
||||
var rotation = view.getRotation();
|
||||
const rotation = view.getRotation();
|
||||
Interaction.rotate(
|
||||
view, rotation, this.anchor_, this.duration_);
|
||||
view, rotation, this.anchor_, this.duration_);
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
@@ -152,7 +152,7 @@ PinchRotate.handleUpEvent_ = function(mapBrowserEvent) {
|
||||
*/
|
||||
PinchRotate.handleDownEvent_ = function(mapBrowserEvent) {
|
||||
if (this.targetPointers.length >= 2) {
|
||||
var map = mapBrowserEvent.map;
|
||||
const map = mapBrowserEvent.map;
|
||||
this.anchor_ = null;
|
||||
this.lastAngle_ = undefined;
|
||||
this.rotating_ = false;
|
||||
|
||||
Reference in New Issue
Block a user