refactor(): use const and let instead of var
This commit is contained in:

committed by
Victor Berchet

parent
73593d4bf3
commit
77ee27c59e
@ -20,8 +20,8 @@ export class AnimationGroupPlayer implements AnimationPlayer {
|
||||
public parentPlayer: AnimationPlayer = null;
|
||||
|
||||
constructor(private _players: AnimationPlayer[]) {
|
||||
var count = 0;
|
||||
var total = this._players.length;
|
||||
let count = 0;
|
||||
const total = this._players.length;
|
||||
if (total == 0) {
|
||||
scheduleMicroTask(() => this._onFinish());
|
||||
} else {
|
||||
@ -93,9 +93,9 @@ export class AnimationGroupPlayer implements AnimationPlayer {
|
||||
}
|
||||
|
||||
getPosition(): number {
|
||||
var min = 0;
|
||||
let min = 0;
|
||||
this._players.forEach(player => {
|
||||
var p = player.getPosition();
|
||||
const p = player.getPosition();
|
||||
min = Math.min(p, min);
|
||||
});
|
||||
return min;
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
import {AnimationPlayer} from './animation_player';
|
||||
|
||||
var _queuedAnimations: AnimationPlayer[] = [];
|
||||
let _queuedAnimations: AnimationPlayer[] = [];
|
||||
|
||||
/** @internal */
|
||||
export function queueAnimation(player: AnimationPlayer) {
|
||||
@ -26,8 +26,8 @@ export function triggerQueuedAnimations() {
|
||||
}
|
||||
|
||||
function _triggerAnimations() {
|
||||
for (var i = 0; i < _queuedAnimations.length; i++) {
|
||||
var player = _queuedAnimations[i];
|
||||
for (let i = 0; i < _queuedAnimations.length; i++) {
|
||||
const player = _queuedAnimations[i];
|
||||
player.play();
|
||||
}
|
||||
_queuedAnimations = [];
|
||||
|
@ -36,7 +36,7 @@ export class AnimationSequencePlayer implements AnimationPlayer {
|
||||
this._activePlayer = new NoOpAnimationPlayer();
|
||||
this._onFinish();
|
||||
} else {
|
||||
var player = this._players[this._currentIndex++];
|
||||
const player = this._players[this._currentIndex++];
|
||||
player.onDone(() => this._onNext(true));
|
||||
|
||||
this._activePlayer = player;
|
||||
|
@ -15,7 +15,7 @@ import {AUTO_STYLE} from './metadata';
|
||||
export function prepareFinalAnimationStyles(
|
||||
previousStyles: {[key: string]: string | number}, newStyles: {[key: string]: string | number},
|
||||
nullValue: string = null): {[key: string]: string} {
|
||||
var finalStyles: {[key: string]: string} = {};
|
||||
const finalStyles: {[key: string]: string} = {};
|
||||
|
||||
Object.keys(newStyles).forEach(prop => {
|
||||
const value = newStyles[prop];
|
||||
@ -34,14 +34,14 @@ export function prepareFinalAnimationStyles(
|
||||
export function balanceAnimationKeyframes(
|
||||
collectedStyles: {[key: string]: string | number},
|
||||
finalStateStyles: {[key: string]: string | number}, keyframes: any[]): any[] {
|
||||
var limit = keyframes.length - 1;
|
||||
var firstKeyframe = keyframes[0];
|
||||
const limit = keyframes.length - 1;
|
||||
const firstKeyframe = keyframes[0];
|
||||
|
||||
// phase 1: copy all the styles from the first keyframe into the lookup map
|
||||
var flatenedFirstKeyframeStyles = flattenStyles(firstKeyframe.styles.styles);
|
||||
const flatenedFirstKeyframeStyles = flattenStyles(firstKeyframe.styles.styles);
|
||||
|
||||
var extraFirstKeyframeStyles: {[key: string]: string} = {};
|
||||
var hasExtraFirstStyles = false;
|
||||
const extraFirstKeyframeStyles: {[key: string]: string} = {};
|
||||
let hasExtraFirstStyles = false;
|
||||
Object.keys(collectedStyles).forEach(prop => {
|
||||
const value = collectedStyles[prop] as string;
|
||||
// if the style is already defined in the first keyframe then
|
||||
@ -53,15 +53,15 @@ export function balanceAnimationKeyframes(
|
||||
}
|
||||
});
|
||||
|
||||
var keyframeCollectedStyles = StringMapWrapper.merge({}, flatenedFirstKeyframeStyles);
|
||||
const keyframeCollectedStyles = StringMapWrapper.merge({}, flatenedFirstKeyframeStyles);
|
||||
|
||||
// phase 2: normalize the final keyframe
|
||||
var finalKeyframe = keyframes[limit];
|
||||
const finalKeyframe = keyframes[limit];
|
||||
finalKeyframe.styles.styles.unshift(finalStateStyles);
|
||||
|
||||
var flatenedFinalKeyframeStyles = flattenStyles(finalKeyframe.styles.styles);
|
||||
var extraFinalKeyframeStyles: {[key: string]: string} = {};
|
||||
var hasExtraFinalStyles = false;
|
||||
const flatenedFinalKeyframeStyles = flattenStyles(finalKeyframe.styles.styles);
|
||||
const extraFinalKeyframeStyles: {[key: string]: string} = {};
|
||||
let hasExtraFinalStyles = false;
|
||||
Object.keys(keyframeCollectedStyles).forEach(prop => {
|
||||
if (!isPresent(flatenedFinalKeyframeStyles[prop])) {
|
||||
extraFinalKeyframeStyles[prop] = AUTO_STYLE;
|
||||
@ -88,7 +88,7 @@ export function balanceAnimationKeyframes(
|
||||
}
|
||||
|
||||
export function clearStyles(styles: {[key: string]: string | number}): {[key: string]: string} {
|
||||
var finalStyles: {[key: string]: string} = {};
|
||||
const finalStyles: {[key: string]: string} = {};
|
||||
Object.keys(styles).forEach(key => { finalStyles[key] = null; });
|
||||
return finalStyles;
|
||||
}
|
||||
@ -96,7 +96,7 @@ export function clearStyles(styles: {[key: string]: string | number}): {[key: st
|
||||
export function collectAndResolveStyles(
|
||||
collection: {[key: string]: string | number}, styles: {[key: string]: string | number}[]) {
|
||||
return styles.map(entry => {
|
||||
var stylesObj: {[key: string]: string | number} = {};
|
||||
const stylesObj: {[key: string]: string | number} = {};
|
||||
Object.keys(entry).forEach(prop => {
|
||||
let value = entry[prop];
|
||||
if (value == FILL_STYLE_FLAG) {
|
||||
@ -118,7 +118,7 @@ export function renderStyles(
|
||||
}
|
||||
|
||||
export function flattenStyles(styles: {[key: string]: string | number}[]): {[key: string]: string} {
|
||||
var finalStyles: {[key: string]: string} = {};
|
||||
const finalStyles: {[key: string]: string} = {};
|
||||
styles.forEach(entry => {
|
||||
Object.keys(entry).forEach(prop => { finalStyles[prop] = entry[prop] as string; });
|
||||
});
|
||||
|
@ -183,9 +183,9 @@ export class AnimationGroupMetadata extends AnimationWithStepsMetadata {
|
||||
export function animate(
|
||||
timing: string | number, styles: AnimationStyleMetadata | AnimationKeyframesSequenceMetadata =
|
||||
null): AnimationAnimateMetadata {
|
||||
var stylesEntry = styles;
|
||||
let stylesEntry = styles;
|
||||
if (!isPresent(stylesEntry)) {
|
||||
var EMPTY_STYLE: {[key: string]: string | number} = {};
|
||||
const EMPTY_STYLE: {[key: string]: string | number} = {};
|
||||
stylesEntry = new AnimationStyleMetadata([EMPTY_STYLE], 1);
|
||||
}
|
||||
return new AnimationAnimateMetadata(timing, stylesEntry);
|
||||
@ -326,8 +326,8 @@ export function sequence(steps: AnimationMetadata[]): AnimationSequenceMetadata
|
||||
export function style(
|
||||
tokens: string | {[key: string]: string | number} |
|
||||
Array<string|{[key: string]: string | number}>): AnimationStyleMetadata {
|
||||
var input: Array<{[key: string]: string | number}|string>;
|
||||
var offset: number = null;
|
||||
let input: Array<{[key: string]: string | number}|string>;
|
||||
let offset: number = null;
|
||||
if (typeof tokens === 'string') {
|
||||
input = [<string>tokens];
|
||||
} else {
|
||||
@ -337,7 +337,7 @@ export function style(
|
||||
input = [<{[key: string]: string | number}>tokens];
|
||||
}
|
||||
input.forEach(entry => {
|
||||
var entryOffset = (entry as any /** TODO #9100 */)['offset'];
|
||||
const entryOffset = (entry as any /** TODO #9100 */)['offset'];
|
||||
if (isPresent(entryOffset)) {
|
||||
offset = offset == null ? parseFloat(entryOffset) : offset;
|
||||
}
|
||||
@ -564,7 +564,7 @@ export function keyframes(steps: AnimationStyleMetadata[]): AnimationKeyframesSe
|
||||
*/
|
||||
export function transition(stateChangeExpr: string, steps: AnimationMetadata | AnimationMetadata[]):
|
||||
AnimationStateTransitionMetadata {
|
||||
var animationData = Array.isArray(steps) ? new AnimationSequenceMetadata(steps) : steps;
|
||||
const animationData = Array.isArray(steps) ? new AnimationSequenceMetadata(steps) : steps;
|
||||
return new AnimationStateTransitionMetadata(stateChangeExpr, animationData);
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ export class ViewAnimationMap {
|
||||
private _allPlayers: AnimationPlayer[] = [];
|
||||
|
||||
find(element: any, animationName: string): AnimationPlayer {
|
||||
var playersByAnimation = this._map.get(element);
|
||||
const playersByAnimation = this._map.get(element);
|
||||
if (isPresent(playersByAnimation)) {
|
||||
return playersByAnimation[animationName];
|
||||
}
|
||||
@ -29,11 +29,11 @@ export class ViewAnimationMap {
|
||||
}
|
||||
|
||||
set(element: any, animationName: string, player: AnimationPlayer): void {
|
||||
var playersByAnimation = this._map.get(element);
|
||||
let playersByAnimation = this._map.get(element);
|
||||
if (!isPresent(playersByAnimation)) {
|
||||
playersByAnimation = {};
|
||||
}
|
||||
var existingEntry = playersByAnimation[animationName];
|
||||
const existingEntry = playersByAnimation[animationName];
|
||||
if (isPresent(existingEntry)) {
|
||||
this.remove(element, animationName);
|
||||
}
|
||||
|
Reference in New Issue
Block a user