You will not find better!

Light weight JavaScript library for text writing effect, with complete attribute based system
A JavaScript free library for you.

Documentation

# Geting Started!


WriteIt.js can be downloaded from here, Or you can use jsDelivr CDN.
Place the following script tag at the end of body tag.

<script src='https://cdn.jsdelivr.net/gh/khushit-shah/WriteIt.js@version/writeit.min.js'></script>

# Functionalities!


WriteIt.js follows attribute based system, you can define an animation by adding attributes. Combine multiple attributes and get different animations.

Following are all the attribute supported!

  • writeit-animate
  • writeit-autostart
  • writeit-char
  • writeit-replace-next
  • writeit-speed
  • writeit-speed-fixed
  • writeit-start-delay
  • writeit-loop
  • writeit-loop-reverse
  • writeit-next
  • writeit-has-prev
  • writeit-hidden
  • writeit-no-blink
  • $`` and ${}
  • writeit-wait-in-reverse and writeit-write-all-in-reverse
  • javascript API

# writeit-animate


It animates the element for once and then animates infinite blinking cursor.

<p writeit-animate>Made with Love 💖</p>

Made with Love 💖

# writeit-autostart


It automatically starts animation of all the elements with writeit-*, you can define it in any tag

<body writeit-autostart>..body..</body>

You can also start animation of all elements with javascript.

<script>WriteItJS.startAnimation()</script>

# writeit-char


It defines the cursor character.

<p writeit-char="🙂" writeit-animate>Always smile!</p>

Always smile!

You can set cursor to any valid html.

<p writeit-char="<span style='color:red'>RED</span>" writeit-animate>Always smile!</p>

redrrrr

Or even an image :)

<p writeit-char="<img src='/assets/img/sample.jpeg' width='16px'>" writeit-animate>Iron Man!</p>

Iron Man!

# writeit-replace-next


Animates different words/senteces on same element. It first animates elements inner-text then it will check for writeit-replace-next attribute, if present it will animate them

<p writeit-replace-next="By,Khushit Shah" writeit-animate>Made With Love!</p>

Made with Love!

You can add ',' into sentences by \,

<p writeit-replace-next="first\, still first, second" writeit-animate>arrays start from zero</p>

Array starts from zero

# writeit-speed


Defines time in millis to animate in/out one character. If not defined uses random speed between 5.5-7.5ms per character. Animation speed may differ by ± 1 to give realistic typing effect

<p writeit-speed='7' writeit-animate>Made With Love!</p>
<p writeit-speed='8.4' writeit-animate>Made With Love!</p>

Made with Love!

Made with Love!

# writeit-speed-fixed


Defines fixed time in millis to animate in/out one character, all characters will be animated at same rate.

<p writeit-speed-fixed='7' writeit-animate>Made With Love!</p>
<p writeit-speed-fixed='8.4' writeit-animate>Made With Love!</p>

Made with Love!

Made with Love!

# writeit-start-delay


Starts the animation after some specified delay in seconds.

<p writeit-start-delay='5' writeit-animate>Take a deep breath for 5 seconds</p>

Take a deep breath for 5 seconds

# writeit-loop


Continously loops the same animation.

<p writeit-loop writeit-animate>loop loop loop</p>

loop loop loop

You can use writeit-loop with writeit-replace-next

<p writeit-loop writeit-replace-next='Hello, World!' writeit-animate>Hello</p>

Hello

So, it continously repeats the animation for infinity.

# writeit-loop-reverse


Same as writeit-loop but also adds deleting animation.

<p writeit-loop-reverse writeit-animate>reverse loop loop loop</p>

reverse loop loop loop

You can use writeit-loop-reverse with writeit-replace-next

<p writeit-loop-reverse writeit-replace-next='Hello, World!' writeit-animate>Hello</p>

Hello

NOTE: writeit-loop or writeit-loop-reverse will only animate inner text of elements with writeit-replace-next attribute once.

# writeit-next & writeit-has-prev


Animates other elements after the current element is animated, it takes the selector for next elements seperated by ',' as value

<p writeit-next='#p1' writeit-animate>It will start animation of another element</p>
<p id='p1' writeit-animate>This will ne messed up...</p>

It will start animation of another element

This will be messed up...

It gets messed up becouse animation of #p1 is already running and it starts animating the same node again So, we need to prevent #p1 from animating until it is from other element or startAnimationOfNode('#p1') is explicitly called. We can use writeit-has-prev or don't add writeit-animate attribute.

<p writeit-next='#p2' writeit-animate>It will start animation of another element</p>
<p id='p2' writeit-has-prev writeit-animate>This will work fine</p>

It will start animation of another element

This will be work fine

Starting animation of multiple nodes

<p writeit-next='#p,#q' writeit-animate>It will start animation of another element</p>
<p id='p' writeit-has-prev writeit-animate>this Works</p>
<p id='q' writeit-has-prev writeit-animate>this Works</p>

It will start animation of another element

This Works

This Works

# writeit-hidden


As you show in previous example next element is shown while the previous element is animating,

writeit-hidden can be used to hide an element until its animation is not started

<p writeit-next='#p2' writeit-animate>It will start animation of another element</p>
<p id='p3' writeit-hidden writeit-has-prev writeit-animate>This is invisible</p>

It will start animation of another element

This is invisible

# writeit-no-blink


Will not animate infinite blinking cursor at the end!

<p writeit-no-blink writeit-animate>No blinking cursor 😱️ </p>

No blinking cursor 😱️

# $`` and ${}


All the text into $`` will not be animated and will be writtern in one throw.

${second} will pause the animation of given element for specified time.

<p writeit-animate>This is fast, wait${3} $`Finished!`</p>

This is fast, wait ${3} $`Finished!`

# writeit-wait-in-reverse and writeit-write-all-in-reverse


if writeit-wait-in reverse is specified, animation will also get affected by ${} in reverse mode.

if writeit-write-all-in-reverse is specified, animation will also get affected by $`` in reverse mode.

wihtout attributes

With attributes

<p writeit-loop-reverse writeit-wait-in-reverse writeit-write-all-in-reverse writeit-animate>This is fast, wait${3},$`Finished!`..</p>

This is fast, wait ${3} $`Finished!`..

# writeit javascript API


Even though you don't need to write a single line of javascript but still there are some functions you can use.

1. startAnimation() - starts the parsing of web page and animation of all nodes.

2. startAnimationOfNode(<selector of node>) - starts the animation of node from start.

3. pauseAnimation(<selector of node>) - pauses animation of node.

4. resumeAnimation(<selector of node>) - resumes animation of node.

E.g using startAnimationOfNode() when the node becomes visible to user