| 305 | } |
| 306 | } |
| 307 | fx5() { |
| 308 | // max iterations for each cell to change the current value |
| 309 | const MAX_CELL_ITERATIONS = 30; |
| 310 | let finished = 0; |
| 311 | this.clearCells(); |
| 312 | |
| 313 | const loop = (line, cell, iteration = 0) => { |
| 314 | cell.cache = {'state': cell.state, 'color': cell.color}; |
| 315 | |
| 316 | if ( iteration === MAX_CELL_ITERATIONS-1 ) { |
| 317 | cell.color = cell.originalColor; |
| 318 | cell.DOM.el.style.color = cell.color; |
| 319 | cell.set(cell.original); |
| 320 | |
| 321 | ++finished; |
| 322 | if ( finished === this.totalChars ) { |
| 323 | this.isAnimating = false; |
| 324 | } |
| 325 | } |
| 326 | else if ( cell.position === 0 ) { |
| 327 | cell.color = ['#3e775d', '#61dca3', '#61b3dc'][Math.floor(Math.random() * 3)] |
| 328 | cell.DOM.el.style.color = cell.color |
| 329 | cell.set(iteration < 9 ? |
| 330 | ['*', '-', '\u0027', '\u0022'][Math.floor(Math.random() * 4)] : |
| 331 | this.getRandomChar()); |
| 332 | } |
| 333 | else { |
| 334 | cell.set(line.cells[cell.previousCellPosition].cache.state); |
| 335 | |
| 336 | cell.color = line.cells[cell.previousCellPosition].cache.color |
| 337 | cell.DOM.el.style.color = cell.color |
| 338 | } |
| 339 | |
| 340 | if ( cell.cache.state != ' ' ) { |
| 341 | ++iteration; |
| 342 | } |
| 343 | |
| 344 | if ( iteration < MAX_CELL_ITERATIONS ) { |
| 345 | setTimeout(() => loop(line, cell, iteration), 10); |
| 346 | } |
| 347 | }; |
| 348 | |
| 349 | for (const line of this.lines) { |
| 350 | for (const cell of line.cells) { |
| 351 | setTimeout(() => loop(line, cell), (line.position+1)*200); |
| 352 | } |
| 353 | } |
| 354 | } |
| 355 | fx6() { |
| 356 | // max iterations for each cell to change the current value |
| 357 | const MAX_CELL_ITERATIONS = 15; |