MCPcopy Create free account
hub / github.com/codrops/TypeShuffleAnimation / fx3

Method fx3

src/js/typeShuffle.js:240–268  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

238 }
239 }
240 fx3() {
241 const MAX_CELL_ITERATIONS = 10;
242 let finished = 0;
243 this.clearCells();
244
245 const loop = (line, cell, iteration = 0) => {
246 if ( iteration === MAX_CELL_ITERATIONS-1 ) {
247 cell.set(cell.original);
248 ++finished;
249 if ( finished === this.totalChars ) {
250 this.isAnimating = false;
251 }
252 }
253 else {
254 cell.set(this.getRandomChar());
255 }
256
257 ++iteration;
258 if ( iteration < MAX_CELL_ITERATIONS ) {
259 setTimeout(() => loop(line, cell, iteration), 80);
260 }
261 };
262
263 for (const line of this.lines) {
264 for (const cell of line.cells) {
265 setTimeout(() => loop(line, cell), randomNumber(0,2000));
266 }
267 }
268 }
269 fx4() {
270 const MAX_CELL_ITERATIONS = 30;
271 let finished = 0;

Callers 1

TypeShuffleClass · 0.95

Calls 2

clearCellsMethod · 0.95
randomNumberFunction · 0.90

Tested by

no test coverage detected