(line, cell, iteration = 0)
| 163 | // cell's loop animation |
| 164 | // each cell will change its value MAX_CELL_ITERATIONS times |
| 165 | const loop = (line, cell, iteration = 0) => { |
| 166 | // cache the previous value |
| 167 | cell.cache = cell.state; |
| 168 | |
| 169 | // set back the original cell value if at the last iteration |
| 170 | if ( iteration === MAX_CELL_ITERATIONS-1 ) { |
| 171 | cell.set(cell.original); |
| 172 | ++finished; |
| 173 | if ( finished === this.totalChars ) { |
| 174 | this.isAnimating = false; |
| 175 | } |
| 176 | } |
| 177 | // if the cell is the first one in its line then generate a random char |
| 178 | else if ( cell.position === 0 ) { |
| 179 | // show specific characters for the first 9 iterations (looks cooler) |
| 180 | cell.set(iteration < 9 ? |
| 181 | ['*', '-', '\u0027', '\u0022'][Math.floor(Math.random() * 4)] : |
| 182 | this.getRandomChar()); |
| 183 | } |
| 184 | // get the cached value of the previous cell. |
| 185 | // This will result in the illusion that the chars are sliding from left to right |
| 186 | else { |
| 187 | cell.set(line.cells[cell.previousCellPosition].cache); |
| 188 | } |
| 189 | |
| 190 | // doesn't count if it's an empty space |
| 191 | if ( cell.cache != ' ' ) { |
| 192 | ++iteration; |
| 193 | } |
| 194 | |
| 195 | // repeat... |
| 196 | if ( iteration < MAX_CELL_ITERATIONS ) { |
| 197 | setTimeout(() => loop(line, cell, iteration), 15); |
| 198 | } |
| 199 | }; |
| 200 | |
| 201 | // set delays for each cell animation |
| 202 | for (const line of this.lines) { |
nothing calls this directly
no test coverage detected