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
Top comments (10)
HI, I need some help with this. I created a .ts file with the below content
How do I render it?
You wrote in the usage of typing. Is it not working?
I think there is no element corresponding to
.target
.Is there an end to end tutorial of how I can render a video file out of this. Any pointers would help.
Use
@scenejs/render
github.com/daybrush/scenejs-render
Yes I read about render. The missing piece for me how all these components play together. Will try again and see if I can make something out of it. An end to end tutorial would help though. Thanks for taking time to respond.
Yes. The documentation is still weak. I have not been able to care much because there are many things that I am preparing now.
render helps render scenes set as global variables.
Hi, have you figured out how to export a scene to MP4 format? Can you explain to me how to do this?
Nope, I haven't done it yet. Were you and to automate in browser?
This is cool. Can we use other language characters other than English?
I haven't tried it but it seems to be.