Better variables scoping
This commit is contained in:
@@ -115,8 +115,7 @@ Collection.prototype.clear = function() {
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
Collection.prototype.extend = function(arr) {
|
Collection.prototype.extend = function(arr) {
|
||||||
let i, ii;
|
for (let i = 0, ii = arr.length; i < ii; ++i) {
|
||||||
for (i = 0, ii = arr.length; i < ii; ++i) {
|
|
||||||
this.push(arr[i]);
|
this.push(arr[i]);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
@@ -225,8 +224,7 @@ Collection.prototype.push = function(elem) {
|
|||||||
*/
|
*/
|
||||||
Collection.prototype.remove = function(elem) {
|
Collection.prototype.remove = function(elem) {
|
||||||
const arr = this.array_;
|
const arr = this.array_;
|
||||||
let i, ii;
|
for (let i = 0, ii = arr.length; i < ii; ++i) {
|
||||||
for (i = 0, ii = arr.length; i < ii; ++i) {
|
|
||||||
if (arr[i] === elem) {
|
if (arr[i] === elem) {
|
||||||
return this.removeAt(i);
|
return this.removeAt(i);
|
||||||
}
|
}
|
||||||
@@ -270,8 +268,7 @@ Collection.prototype.setAt = function(index, elem) {
|
|||||||
this.dispatchEvent(
|
this.dispatchEvent(
|
||||||
new CollectionEvent(CollectionEventType.ADD, elem));
|
new CollectionEvent(CollectionEventType.ADD, elem));
|
||||||
} else {
|
} else {
|
||||||
let j;
|
for (let j = n; j < index; ++j) {
|
||||||
for (j = n; j < index; ++j) {
|
|
||||||
this.insertAt(j, undefined);
|
this.insertAt(j, undefined);
|
||||||
}
|
}
|
||||||
this.insertAt(index, elem);
|
this.insertAt(index, elem);
|
||||||
|
|||||||
@@ -172,9 +172,8 @@ PointerEventHandler.prototype.registerSource = function(name, source) {
|
|||||||
*/
|
*/
|
||||||
PointerEventHandler.prototype.register_ = function() {
|
PointerEventHandler.prototype.register_ = function() {
|
||||||
const l = this.eventSourceList_.length;
|
const l = this.eventSourceList_.length;
|
||||||
let eventSource;
|
|
||||||
for (let i = 0; i < l; i++) {
|
for (let i = 0; i < l; i++) {
|
||||||
eventSource = this.eventSourceList_[i];
|
const eventSource = this.eventSourceList_[i];
|
||||||
this.addEvents_(eventSource.getEvents());
|
this.addEvents_(eventSource.getEvents());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -186,9 +185,8 @@ PointerEventHandler.prototype.register_ = function() {
|
|||||||
*/
|
*/
|
||||||
PointerEventHandler.prototype.unregister_ = function() {
|
PointerEventHandler.prototype.unregister_ = function() {
|
||||||
const l = this.eventSourceList_.length;
|
const l = this.eventSourceList_.length;
|
||||||
let eventSource;
|
|
||||||
for (let i = 0; i < l; i++) {
|
for (let i = 0; i < l; i++) {
|
||||||
eventSource = this.eventSourceList_[i];
|
const eventSource = this.eventSourceList_[i];
|
||||||
this.removeEvents_(eventSource.getEvents());
|
this.removeEvents_(eventSource.getEvents());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -219,9 +219,8 @@ TouchSource.prototype.processTouches_ = function(inEvent, inFunction) {
|
|||||||
function preventDefault() {
|
function preventDefault() {
|
||||||
inEvent.preventDefault();
|
inEvent.preventDefault();
|
||||||
}
|
}
|
||||||
let i, pointer;
|
for (let i = 0; i < count; ++i) {
|
||||||
for (i = 0; i < count; ++i) {
|
const pointer = this.touchToPointer_(inEvent, touches[i]);
|
||||||
pointer = this.touchToPointer_(inEvent, touches[i]);
|
|
||||||
// forward touch preventDefaults
|
// forward touch preventDefaults
|
||||||
pointer.preventDefault = preventDefault;
|
pointer.preventDefault = preventDefault;
|
||||||
inFunction.call(this, inEvent, pointer);
|
inFunction.call(this, inEvent, pointer);
|
||||||
@@ -237,9 +236,8 @@ TouchSource.prototype.processTouches_ = function(inEvent, inFunction) {
|
|||||||
*/
|
*/
|
||||||
TouchSource.prototype.findTouch_ = function(touchList, searchId) {
|
TouchSource.prototype.findTouch_ = function(touchList, searchId) {
|
||||||
const l = touchList.length;
|
const l = touchList.length;
|
||||||
let touch;
|
|
||||||
for (let i = 0; i < l; i++) {
|
for (let i = 0; i < l; i++) {
|
||||||
touch = touchList[i];
|
const touch = touchList[i];
|
||||||
if (touch.identifier === searchId) {
|
if (touch.identifier === searchId) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -267,10 +265,9 @@ TouchSource.prototype.vacuumTouches_ = function(inEvent) {
|
|||||||
const count = keys.length;
|
const count = keys.length;
|
||||||
if (count >= touchList.length) {
|
if (count >= touchList.length) {
|
||||||
const d = [];
|
const d = [];
|
||||||
let i, key, value;
|
for (let i = 0; i < count; ++i) {
|
||||||
for (i = 0; i < count; ++i) {
|
const key = keys[i];
|
||||||
key = keys[i];
|
const value = this.pointerMap[key];
|
||||||
value = this.pointerMap[key];
|
|
||||||
// Never remove pointerId == 1, which is mouse.
|
// Never remove pointerId == 1, which is mouse.
|
||||||
// Touch identifiers are 2 smaller than their pointerId, which is the
|
// Touch identifiers are 2 smaller than their pointerId, which is the
|
||||||
// index in pointermap.
|
// index in pointermap.
|
||||||
@@ -279,7 +276,7 @@ TouchSource.prototype.vacuumTouches_ = function(inEvent) {
|
|||||||
d.push(value.out);
|
d.push(value.out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i = 0; i < d.length; ++i) {
|
for (let i = 0; i < d.length; ++i) {
|
||||||
this.cancelOut_(inEvent, d[i]);
|
this.cancelOut_(inEvent, d[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-4
@@ -317,12 +317,11 @@ export function createTransformFromCoordinateTransform(coordTransform) {
|
|||||||
const length = input.length;
|
const length = input.length;
|
||||||
const dimension = opt_dimension !== undefined ? opt_dimension : 2;
|
const dimension = opt_dimension !== undefined ? opt_dimension : 2;
|
||||||
const output = opt_output !== undefined ? opt_output : new Array(length);
|
const output = opt_output !== undefined ? opt_output : new Array(length);
|
||||||
let point, i, j;
|
for (let i = 0; i < length; i += dimension) {
|
||||||
for (i = 0; i < length; i += dimension) {
|
const point = coordTransform([input[i], input[i + 1]]);
|
||||||
point = coordTransform([input[i], input[i + 1]]);
|
|
||||||
output[i] = point[0];
|
output[i] = point[0];
|
||||||
output[i + 1] = point[1];
|
output[i + 1] = point[1];
|
||||||
for (j = dimension - 1; j >= 2; --j) {
|
for (let j = dimension - 1; j >= 2; --j) {
|
||||||
output[i + j] = input[i + j];
|
output[i + j] = input[i + j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user