Ver Fonte

Make let not var (#1298)

Ivan Popelyshev há 6 anos atrás
pai
commit
d55724a1b5

+ 4 - 4
spine-ts/core/src/Animation.ts

@@ -233,7 +233,7 @@ module spine {
 			}
 			}
 
 
 			if (time >= frames[frames.length - RotateTimeline.ENTRIES]) { // Time is after last frame.
 			if (time >= frames[frames.length - RotateTimeline.ENTRIES]) { // Time is after last frame.
-				var r = frames[frames.length + RotateTimeline.PREV_ROTATION];
+				let r = frames[frames.length + RotateTimeline.PREV_ROTATION];
 				switch (blend) {
 				switch (blend) {
 				case MixBlend.setup:
 				case MixBlend.setup:
 					bone.rotation = bone.data.rotation + r * alpha;
 					bone.rotation = bone.data.rotation + r * alpha;
@@ -255,7 +255,7 @@ module spine {
 			let percent = this.getCurvePercent((frame >> 1) - 1,
 			let percent = this.getCurvePercent((frame >> 1) - 1,
 				1 - (time - frameTime) / (frames[frame + RotateTimeline.PREV_TIME] - frameTime));
 				1 - (time - frameTime) / (frames[frame + RotateTimeline.PREV_TIME] - frameTime));
 
 
-			r = frames[frame + RotateTimeline.ROTATION] - prevRotation;
+			let r = frames[frame + RotateTimeline.ROTATION] - prevRotation;
 			r = prevRotation + (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * percent;
 			r = prevRotation + (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * percent;
 			switch (blend) {
 			switch (blend) {
 			case MixBlend.setup:
 			case MixBlend.setup:
@@ -728,7 +728,7 @@ module spine {
 		}
 		}
 	}
 	}
 
 
-	var zeros : ArrayLike<number> = null;
+	let zeros : ArrayLike<number> = null;
 
 
 	export class DeformTimeline extends CurveTimeline {
 	export class DeformTimeline extends CurveTimeline {
 		slotIndex: number;
 		slotIndex: number;
@@ -779,7 +779,7 @@ module spine {
 					let vertices: Array<number> = Utils.setArraySize(verticesArray, vertexCount);
 					let vertices: Array<number> = Utils.setArraySize(verticesArray, vertexCount);
 					if (vertexAttachment.bones == null) {
 					if (vertexAttachment.bones == null) {
 						// Unweighted vertex positions.
 						// Unweighted vertex positions.
-						var setupVertices = vertexAttachment.vertices;
+						let setupVertices = vertexAttachment.vertices;
 						for (var i = 0; i < vertexCount; i++)
 						for (var i = 0; i < vertexCount; i++)
 							vertices[i] += (setupVertices[i] - vertices[i]) * alpha;
 							vertices[i] += (setupVertices[i] - vertices[i]) * alpha;
 					} else {
 					} else {

+ 9 - 9
spine-ts/core/src/AnimationState.ts

@@ -212,7 +212,7 @@ module spine {
 			let timelines = from.animation.timelines;
 			let timelines = from.animation.timelines;
 			let alphaHold = from.alpha * to.interruptAlpha, alphaMix = alphaHold * (1 - mix);
 			let alphaHold = from.alpha * to.interruptAlpha, alphaMix = alphaHold * (1 - mix);
 			if (blend == MixBlend.add) {
 			if (blend == MixBlend.add) {
-				for (var i = 0; i < timelineCount; i++)
+				for (let i = 0; i < timelineCount; i++)
 					timelines[i].apply(skeleton, animationLast, animationTime, events, alphaMix, blend, MixDirection.out);
 					timelines[i].apply(skeleton, animationLast, animationTime, events, alphaMix, blend, MixDirection.out);
 			} else {
 			} else {
 				let timelineMode = from.timelineMode;
 				let timelineMode = from.timelineMode;
@@ -223,11 +223,11 @@ module spine {
 				let timelinesRotation = from.timelinesRotation;
 				let timelinesRotation = from.timelinesRotation;
 
 
 				from.totalAlpha = 0;
 				from.totalAlpha = 0;
-				for (var i = 0; i < timelineCount; i++) {
+				for (let i = 0; i < timelineCount; i++) {
 					let timeline = timelines[i];
 					let timeline = timelines[i];
-					var direction = MixDirection.out;
-					var timelineBlend: MixBlend;
-					var alpha = 0;
+					let direction = MixDirection.out;
+					let timelineBlend: MixBlend;
+					let alpha = 0;
 					switch (timelineMode[i]) {
 					switch (timelineMode[i]) {
 					case AnimationState.SUBSEQUENT:
 					case AnimationState.SUBSEQUENT:
 						if (!attachments && timeline instanceof AttachmentTimeline) continue;
 						if (!attachments && timeline instanceof AttachmentTimeline) continue;
@@ -364,7 +364,7 @@ module spine {
 			}
 			}
 
 
 			// Queue complete if completed a loop iteration or the animation.
 			// Queue complete if completed a loop iteration or the animation.
-			var complete = false;
+			let complete = false;
 			if (entry.loop)
 			if (entry.loop)
 				complete = duration == 0 || trackLastWrapped > entry.trackTime % duration;
 				complete = duration == 0 || trackLastWrapped > entry.trackTime % duration;
 			else
 			else
@@ -577,7 +577,7 @@ module spine {
 
 
 			this.propertyIDs.clear();
 			this.propertyIDs.clear();
 
 
-			for (var i = 0, n = this.tracks.length; i < n; i++) {
+			for (let i = 0, n = this.tracks.length; i < n; i++) {
 				let entry = this.tracks[i];
 				let entry = this.tracks[i];
 				if (entry == null) continue;
 				if (entry == null) continue;
 				while (entry.mixingFrom != null)
 				while (entry.mixingFrom != null)
@@ -608,7 +608,7 @@ module spine {
 			}
 			}
 
 
 			outer:
 			outer:
-			for (var i = 0; i < timelinesCount; i++) {
+			for (let i = 0; i < timelinesCount; i++) {
 				let id = timelines[i].getPropertyId();
 				let id = timelines[i].getPropertyId();
 				if (!propertyIDs.add(id))
 				if (!propertyIDs.add(id))
 					timelineMode[i] = AnimationState.SUBSEQUENT;
 					timelineMode[i] = AnimationState.SUBSEQUENT;
@@ -631,7 +631,7 @@ module spine {
 
 
 		hasTimeline (entry: TrackEntry, id: number) : boolean {
 		hasTimeline (entry: TrackEntry, id: number) : boolean {
 			let timelines = entry.animation.timelines;
 			let timelines = entry.animation.timelines;
-			for (var i = 0, n = timelines.length; i < n; i++)
+			for (let i = 0, n = timelines.length; i < n; i++)
 				if (timelines[i].getPropertyId() == id) return true;
 				if (timelines[i].getPropertyId() == id) return true;
 			return false;
 			return false;
 		}
 		}

+ 2 - 2
spine-ts/core/src/AssetManager.ts

@@ -147,8 +147,8 @@ module spine {
 			this.toLoad++;
 			this.toLoad++;
 
 
 			AssetManager.downloadText(path, (atlasData: string): void => {
 			AssetManager.downloadText(path, (atlasData: string): void => {
-				var pagesLoaded: any = { count: 0 };
-				var atlasPages = new Array<string>();
+				let pagesLoaded: any = { count: 0 };
+				let atlasPages = new Array<string>();
 				try {
 				try {
 					let atlas = new TextureAtlas(atlasData, (path: string) => {
 					let atlas = new TextureAtlas(atlasData, (path: string) => {
 						atlasPages.push(parent + "/" + path);
 						atlasPages.push(parent + "/" + path);

+ 3 - 3
spine-ts/core/src/PathConstraint.ts

@@ -78,7 +78,7 @@ module spine {
 			let spacing = this.spacing;
 			let spacing = this.spacing;
 			if (scale || !percentSpacing) {
 			if (scale || !percentSpacing) {
 				if (scale) lengths = Utils.setArraySize(this.lengths, boneCount);
 				if (scale) lengths = Utils.setArraySize(this.lengths, boneCount);
-				var lengthSpacing = data.spacingMode == SpacingMode.Length;
+				let lengthSpacing = data.spacingMode == SpacingMode.Length;
 				for (let i = 0, n = spacesCount - 1; i < n;) {
 				for (let i = 0, n = spacesCount - 1; i < n;) {
 					let bone = bones[i];
 					let bone = bones[i];
 					let setupLength = bone.data.length;
 					let setupLength = bone.data.length;
@@ -87,8 +87,8 @@ module spine {
 						spaces[++i] = 0;
 						spaces[++i] = 0;
 					} else if (percentSpacing) {
 					} else if (percentSpacing) {
 						if (scale) {
 						if (scale) {
-							var x = setupLength * bone.a, y = setupLength * bone.c;
-							var length = Math.sqrt(x * x + y * y);
+							let x = setupLength * bone.a, y = setupLength * bone.c;
+							let length = Math.sqrt(x * x + y * y);
 							lengths[i] = length;
 							lengths[i] = length;
 						}
 						}
 						spaces[++i] = spacing;
 						spaces[++i] = spacing;

+ 9 - 9
spine-ts/core/src/SharedAssetManager.ts

@@ -40,8 +40,8 @@ module spine {
 		}
 		}
 
 
 		loaded() {
 		loaded() {
-			var i = 0;
-			for (var v in this.assets) i++;
+			let i = 0;
+			for (let v in this.assets) i++;
 			return i;
 			return i;
 		}
 		}
 	}
 	}
@@ -58,7 +58,7 @@ module spine {
 		}
 		}
 
 
 		private queueAsset(clientId: string, textureLoader: (image: HTMLImageElement) => any, path: string): boolean {
 		private queueAsset(clientId: string, textureLoader: (image: HTMLImageElement) => any, path: string): boolean {
-			var clientAssets = this.clientAssets[clientId];
+			let clientAssets = this.clientAssets[clientId];
 			if (clientAssets === null || clientAssets === undefined) {
 			if (clientAssets === null || clientAssets === undefined) {
 				clientAssets = new Assets(clientId);
 				clientAssets = new Assets(clientId);
 				this.clientAssets[clientId] = clientAssets;
 				this.clientAssets[clientId] = clientAssets;
@@ -127,17 +127,17 @@ module spine {
 
 
 		get (clientId: string, path: string) {
 		get (clientId: string, path: string) {
 			path = this.pathPrefix + path;
 			path = this.pathPrefix + path;
-			var clientAssets = this.clientAssets[clientId];
+			let clientAssets = this.clientAssets[clientId];
 			if (clientAssets === null || clientAssets === undefined) return true;
 			if (clientAssets === null || clientAssets === undefined) return true;
 			return clientAssets.assets[path];
 			return clientAssets.assets[path];
 		}
 		}
 
 
 		private updateClientAssets(clientAssets: Assets): void {
 		private updateClientAssets(clientAssets: Assets): void {
-			for (var i = 0; i < clientAssets.toLoad.length; i++) {
-				var path = clientAssets.toLoad[i];
-				var asset = clientAssets.assets[path];
+			for (let i = 0; i < clientAssets.toLoad.length; i++) {
+				let path = clientAssets.toLoad[i];
+				let asset = clientAssets.assets[path];
 				if (asset === null || asset === undefined) {
 				if (asset === null || asset === undefined) {
-					var rawAsset = this.rawAssets[path];
+					let rawAsset = this.rawAssets[path];
 					if (rawAsset === null || rawAsset === undefined) continue;
 					if (rawAsset === null || rawAsset === undefined) continue;
 					if (rawAsset instanceof HTMLImageElement) {
 					if (rawAsset instanceof HTMLImageElement) {
 						clientAssets.assets[path] = clientAssets.textureLoader(<HTMLImageElement>rawAsset);
 						clientAssets.assets[path] = clientAssets.textureLoader(<HTMLImageElement>rawAsset);
@@ -149,7 +149,7 @@ module spine {
 		}
 		}
 
 
 		isLoadingComplete (clientId: string): boolean {
 		isLoadingComplete (clientId: string): boolean {
-			var clientAssets = this.clientAssets[clientId];
+			let clientAssets = this.clientAssets[clientId];
 			if (clientAssets === null || clientAssets === undefined) return true;
 			if (clientAssets === null || clientAssets === undefined) return true;
 			this.updateClientAssets(clientAssets);
 			this.updateClientAssets(clientAssets);
 			return clientAssets.toLoad.length == clientAssets.loaded();
 			return clientAssets.toLoad.length == clientAssets.loaded();

+ 2 - 2
spine-ts/core/src/Utils.ts

@@ -155,7 +155,7 @@ module spine {
 		}
 		}
 
 
 		static cbrt (x: number) {
 		static cbrt (x: number) {
-			var y = Math.pow(Math.abs(x), 1/3);
+			let y = Math.pow(Math.abs(x), 1/3);
 			return x < 0 ? -y : y;
 			return x < 0 ? -y : y;
 		}
 		}
 
 
@@ -341,7 +341,7 @@ module spine {
 		private frameTime = 0;
 		private frameTime = 0;
 
 
 		update () {
 		update () {
-			var now = Date.now() / 1000;
+			let now = Date.now() / 1000;
 			this.delta = now - this.lastTime;
 			this.delta = now - this.lastTime;
 			this.frameTime += this.delta;
 			this.frameTime += this.delta;
 			this.totalTime += this.delta;
 			this.totalTime += this.delta;