JSFiddle - React, Tailwind, and code Playground

by rwhal06

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id="test" class="fancy_title">
      <canvas width=600 height=100></canvas>
</div>

SCSS

@import url('https://fonts.googleapis.com/css?family=Cookie');
body {
		background-color: #000;
	}

#test { 
position:absolute; 
left:0; 
right:0; 
height:100px; 
margin: 0 auto; 
text-align:center;
  width: 100%;
}


#test canvas { 
margin:0 auto; 
text-align:center;    

}
@keyframes fadeInLeft {
    0% { 
        opacity: 0; 
        -webkit-transform: translateX(-15px); 
    } 
    100% { 
        opacity: 1; 
        -webkit-transform: translateX(0); 
    } 
}

/* Firefox < 16 */
@-moz-keyframes fadeInLeft {
    0% { 
        opacity: 0; 
        -webkit-transform: translateX(-15px); 
    } 
    100% { 
        opacity: 1; 
        -webkit-transform: translateX(0); 
    } 
}

/* Safari, Chrome and Opera > 12.1 */
@-webkit-keyframes fadeInLeft {
    0% { 
        opacity: 0; 
        -webkit-transform: translateX(-15px); 
    } 
    100% { 
        opacity: 1; 
        -webkit-transform: translateX(0); 
    } 
}

/* Internet Explorer */
@-ms-keyframes fadeInLeft {
   0% { 
        opacity: 0; 
        -webkit-transform: translateX(-15px); 
    } 
    100% { 
        opacity: 1; 
        -webkit-transform: translateX(0); 
    } 
}

/* Opera < 12.1 */
@-o-keyframes fadeInLeft {
   0% { 
        opacity: 0; 
        -webkit-transform: translateX(-15px); 
    } 
    100% { 
        opacity: 1; 
        -webkit-transform: translateX(0); 
    } 
}

JavaScript

//$(".fancy_title p").lettering();

// get 2D context
	var ctx = document.querySelector("canvas").getContext("2d"),
	
	    // dash-length for off-range
        dashLen = 220,
		
		// we'll update this, initialize
        dashOffset = dashLen,
		
		// some arbitrary speed
        speed = 30,
		
		// the text we will draw
        txt = "“Prosperity of every kind is drawn to me.”",
		
		// start position for x and iterator
		x = 30, i = 0;

// Comic Sans?? Let's make it useful for something ;) w/ fallbacks
    //ctx.font = "50px Loved by the King"; 
    ctx.font = "italic 50px Cookie";
	
	// thickness of the line
   // ctx.lineWidth = 1; 
	
	// to avoid spikes we can join each line with a round joint
	//ctx.lineJoin = "round";
	
	// increase realism letting background (f.ex. paper) show through
	//ctx.globalAlpha = 2/3;
	
	// some color, lets use a black pencil
    ctx.strokeStyle = ctx.fillStyle = "#FFF";


(function loop() {
      // clear canvas for each frame
      ctx.clearRect(x, 0, 60, 150);
      
      // calculate and set current line-dash for this char
      ctx.setLineDash([dashLen - dashOffset, dashOffset - speed]);
      
      // reduce length of off-dash
      dashOffset -= speed;
      
      // draw char to canvas with current dash-length
      ctx.strokeText(txt[i], x, 90);

      // char done? no, the loop
      if (dashOffset > 0) requestAnimationFrame(loop);
      else {
      
        // ok, outline done, lets fill its interior before next
        ctx.fillText(txt[i], x, 90);
        
        // reset line-dash length
        dashOffset = dashLen;
        
        // get x position to next char by measuring what we have drawn
        // notice we offset it a little by random to increase realism
        x += ctx.measureText(txt[i++]).width + ctx.lineWidth * Math.random();
        
        // lets use an absolute transform to randomize y-position a little
        //ctx.setTransform(1, 0, 0, 1, 0, 3 * Math.random());
        
        // and just...