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

Method fx2

src/js/typeShuffle.js:208–239  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

206 }
207 }
208 fx2() {
209 const MAX_CELL_ITERATIONS = 20;
210 let finished = 0;
211 const loop = (line, cell, iteration = 0) => {
212 if ( iteration === MAX_CELL_ITERATIONS-1 ) {
213 cell.set(cell.original);
214 cell.DOM.el.style.opacity = 0;
215 setTimeout(() => {
216 cell.DOM.el.style.opacity = 1;
217 }, 300);
218
219 ++finished;
220 if ( finished === this.totalChars ) {
221 this.isAnimating = false;
222 }
223 }
224 else {
225 cell.set(this.getRandomChar());
226 }
227
228 ++iteration;
229 if ( iteration < MAX_CELL_ITERATIONS ) {
230 setTimeout(() => loop(line, cell, iteration), 40);
231 }
232 };
233
234 for (const line of this.lines) {
235 for (const cell of line.cells) {
236 setTimeout(() => loop(line, cell), (cell.position+1)*30);
237 }
238 }
239 }
240 fx3() {
241 const MAX_CELL_ITERATIONS = 10;
242 let finished = 0;

Callers 1

TypeShuffleClass · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected