Giter VIP home page Giter VIP logo

Comments (6)

qroft avatar qroft commented on July 20, 2024 2

Maybe i am wrong, but when i open that jsFiddle above, there are absolutely NO new lines in the result animation.

from typewriterjs.

tameemsafi avatar tameemsafi commented on July 20, 2024 1

You can now add HTML tags inside of the strings. So you can add a <br /> tag and it will work like a new line in HTML.

var app = document.getElementById('app');

var typewriter = new Typewriter(app, {
    loop: true
});

typewriter.typeString('<strong>Human: </strong>')
    .typeString('Hello how are you?')
    .pauseFor(2500)
    .typeString('<br/>')
    .typeString('<strong>Bot: </strong>')
    .typeString('I am fine thanks, how are you?')
    .pauseFor(2500)
    .typeString('<br/>')
    .typeString('<strong>Human: </strong> ')
    .typeString('I am great!')
    .pauseFor(2500)
    .start();

See jsfiddle here: https://jsfiddle.net/shbqy0mv/9/
This only works on v2.3.1 and above.

from typewriterjs.

hacking-robot avatar hacking-robot commented on July 20, 2024

you could write a method newline() that would be chained.

from typewriterjs.

12monkeys avatar 12monkeys commented on July 20, 2024

You could use whatever character you need changing this to make a newline:

TypewriterPrototype._convertCharsToHTML = function (chars)
{
	var chars_html_wrap_array = [];
	var char_class_name = this.options.charSpanClassName;
	var chars_array = chars[0];
	for (var i = 0, length = chars_array.length; i < length; i++)
	{
		var char_element = document.createElement('span');
		var char_id = this._generateUniqueID();
		char_element.id = char_id;
		char_element.className = char_class_name + ' typewriter-item-' + i;
		char_element.innerHTML = chars_array[i]=="#"?"<br>":chars_array[i]; //ADDED # to make NEWLINE
		chars_html_wrap_array.push(
		{
			id: char_id,
			el: char_element
		});
	}
	return chars_html_wrap_array;
};

from typewriterjs.

AndyLIUMel avatar AndyLIUMel commented on July 20, 2024

Try it in Chrome

from typewriterjs.

r3hab-media avatar r3hab-media commented on July 20, 2024

I'm using this in chrome. There are no line breaks. The
are being literally typed out. Has this issue been solved?

Here's a pen: https://codepen.io/newnam/pen/rNBGXPY

from typewriterjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.