I write a post to inform you that I have added a typing effect to Scene.js Effects library.

https://github.com/daybrush/scenejs-effects

In this article, I want to introduce the principles of typing animation.

Typing Animation

There are three typical ways to make typing animations.

JavaScript Animation CSS Animation (PC Chrome Only) SVG Animation

The animation to be described in this article is JavaScript.

Because it's simpler than I thought.

CSS animation can also create typing animations using the before or after pseudo selector and content properties. However, since it is a selector that only supports PC Chrome, it is too much to use.

If your browser is PC Chrome, you will see the animation below.



Typing animation is a method of importing text sequentially into html as shown below.



const text = " Make a typing effect with Scene.js. " ; const length = text . length ; for ( let i = 0 ; i <= length ; ++ i ) { element . innerHTML = text . substring ( start , i ); }

Once you create a typing animation using Scene.js, you can write the code as follows:



Scene . typing ({ text : " Make a typing effect with Scene.js. " });

Play the above code and it will look like the following CodePen:



Kinetic Animation

In addition to typing animation, it tries to have a kinetic effect.

The kinetic effect moves the origin point in the opposite direction.

The origin point appears to be fixed but is moving.



.kinetic { transform : translate ( 20px , -40px ); transform-origin : calc ( 50% - 20px ) calc ( 50% + 40px ); }

Once you create a kinetic animation using Scene.js, you can write the code as follows:



Scene . kineticFrame ({ left : " 20px " , top : " -40px " });

Play the above code and it will look like the following CodePen:



Kinetic Typing Animation

Finally, add typing animation in time for kinetic effect.



scene . set ({ " [data-typing='i'] " : Scene . typing ({ text : " I " , duration : 1 }), " [data-typing='frontend'] " : { 1 : Scene . typing ({ text : " 'm Front-End " , duration : 1 }), }, " [data-typing='engineer'] " : { 1.5 : Scene . typing ({ text : " Engineer " , duration : 1 }), }, " [data-typing='with'] " : { 3.3 : Scene . typing ({ text : " with " , duration : 0.5 }), }, // ... });

Finally, if you tie the typing effect to the kinetic effect, it will be as follows:



Check out my projects at the following link.

https://github.com/daybrush/scenejs

https://github.com/daybrush/scenejs-effects

If you like it, press the star.

If you have the features or questions you want, please register the issue or write down the questions at any time.

Thank you