11// tslint:disable:no-input-rename
22
3- import {
4- ChangeDetectionStrategy ,
5- Component ,
6- Input ,
7- OnChanges ,
8- SimpleChanges ,
9- OnInit ,
10- ViewEncapsulation ,
11- ContentChild ,
12- TemplateRef ,
13- ElementRef ,
14- OnDestroy ,
15- } from '@angular/core' ;
16- import { DomSanitizer , SafeStyle } from '@angular/platform-browser' ;
3+ import { Component , OnInit , ContentChild , TemplateRef , ElementRef , OnDestroy } from '@angular/core' ;
174
185export const COLORS = { default : { text : '#222' , bg : '#ddd' } , hover : { text : '#fff' , bg : '#0078D4' } } ;
196export const DEFAULT_DOT_SIZE = 25 ;
@@ -46,7 +33,7 @@ export class TriangleComponent implements OnInit, OnDestroy {
4633 private startTime : number ; // In milliseconds
4734 private counter = 0 ; // Revolving counter, 0-9 and back again.
4835 private _scale : number ; // Moves from 1 to 1.5 and back to 1 at a set rate based on time elapsed.
49- private timer : NodeJS . Timer ; // Repeating timer that updates the counter once per second.
36+ private timer : number ; // Repeating timer that updates the counter once per second.
5037 private _dots : Array < SierpinskiTriangleDot > ; // Collection of dot objects, rendered by the dotTemplate.
5138 public isActive : boolean ; // Used to indicate active looping and to prevent further looping (stop).
5239
@@ -106,9 +93,9 @@ export class TriangleComponent implements OnInit, OnDestroy {
10693 // the updates as it is aware of each node being updated. React struggles
10794 // with this update since it is not holistically aware of every node
10895 // being updated. Although React Fiber optimizes updates to prevent
109- // blocking the single thread and interupting high priority updates such
96+ // blocking the single thread and interrupting high priority updates such
11097 // as animation, each individual React node schedules it's update without
111- // knowledge of the other nodes (dots) and they all atempt to update
98+ // knowledge of the other nodes (dots) and they all attempt to update
11299 // at the same time, blocking the thread. Further investigation is needed
113100 // to see if there is a way for the separate React dots to share a scheduler
114101 // and coordinate DOM updates.
@@ -120,7 +107,7 @@ export class TriangleComponent implements OnInit, OnDestroy {
120107
121108 // Update the counter (the number shown on each dot).
122109 this . startTime = new Date ( ) . getTime ( ) ;
123- this . timer = setInterval ( ( ) => this . updateCounter ( ) , this . interval ) ;
110+ this . timer = setInterval ( ( ) => this . updateCounter ( ) , this . interval ) as any ;
124111
125112 // Update the scale value for the container (applied via css transform
126113 // on the container).
@@ -170,7 +157,6 @@ class SierpinskiTriangle {
170157 if ( size <= targetSize ) {
171158 this . dot = new SierpinskiTriangleDot ( x - targetSize / 2 , y - targetSize / 2 , targetSize ) ;
172159 } else {
173- const newSize = size / 2 ;
174160 size /= 2 ;
175161 this . triangles = [
176162 new SierpinskiTriangle ( { x, y : y - size / 2 , size, targetSize } ) ,
@@ -188,7 +174,7 @@ class SierpinskiTriangle {
188174class SierpinskiTriangleDot {
189175 hover = false ;
190176
191- constructor ( private _x , private _y , private _size ) { }
177+ constructor ( private readonly _x : number , private readonly _y : number , private readonly _size : number ) { }
192178
193179 get x ( ) {
194180 return this . _x + 'px' ;
0 commit comments