assets/js/typewriter2.js
// keeps calling itself until the text is finished
keeps calling itself until the text is finished
keeps calling itself until the text is finished
function typeWriter(text, i, fnCallback) {
      if (i < (text.length)) {
       document.querySelector("h1").innerHTML = text.substring(0, i+1) +'<span class="writer" aria-hidden="true"></span>';
        setTimeout(function() {
          typeWriter(text, i + 1, fnCallback)
        }, 100);
      }
      else if (typeof fnCallback == 'function') {
        setTimeout(fnCallback, 700);
      }
    }
function typeWriter ( text , i , fnCallback ) { if ( i < ( text . length ) ) { document . querySelector ( "h1" ) . innerHTML = text . substring ( 0 , i + 1 ) + '<span class="writer" aria-hidden="true"></span>' ; setTimeout ( function ( ) { typeWriter ( text , i + 1 , fnCallback ) } , 100 ) ; } else if ( typeof fnCallback == 'function' ) { setTimeout ( fnCallback , 700 ) ; } }
keeps calling itself until the text is finished
keeps calling itself until the text is finished
// chekc if text isn't finished yet // add next character to h1 // wait for a while and call this function again for next character // text finished, call callback if there is a callback function // call callback after timeout