HTML returns undefined

HTML returns undefined on <p> tag

 

var ani;
$(document).ready(function(){
	ani = new Animate_text("test sentence", false, 30);
	ani.writer();
});



class Animate_text{
	
	constructor(text, dynamic, speed){
		this.text = text;
		this.speed = speed;
		this.dynamic = dynamic;
		this.chars = text.length;
		this.text_loc = 0;
		this.timerID = null;
		this.animate_image = false;
	}

	writer(){
	var sContents = "";
	var destination = document.getElementById("text");
	destination.innerHTML = sContents + this.text.substring(0, this.text_loc) + "";
	
	if ( this.text_loc++ == this.chars ) {
		this.text_loc = 0;
		if (this.dynamic) {
			window.clearTimeout(this.timerID);
			// animation.setup();
			// animation.draw_points();
			ani = null;
		}else{
			window.clearTimeout(this.timerID);
			this.animate_image = true;
			//here we call the animate class
			// animate_image.draw_text();
			ani = null;
		}
	}else{
		this.timerID = setTimeout(function(){
			if(ani != null){
				ani.writer();
			}
		}, this.speed)
	}
}
}

LEAVE A REPLY

Please enter your comment!
Please enter your name here