<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ola B</title>
    <description>The latest articles on DEV Community by Ola B (@vakme).</description>
    <link>https://dev.to/vakme</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F216661%2Fd3182017-b0fd-45db-aa51-8aa3e5758225.png</url>
      <title>DEV Community: Ola B</title>
      <link>https://dev.to/vakme</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vakme"/>
    <language>en</language>
    <item>
      <title>Know Your WebDev Math: Dynamic positioning with trigonometry</title>
      <dc:creator>Ola B</dc:creator>
      <pubDate>Fri, 29 May 2026 14:09:33 +0000</pubDate>
      <link>https://dev.to/vakme/know-your-webdev-math-dynamic-positioning-with-trigonometry-2co6</link>
      <guid>https://dev.to/vakme/know-your-webdev-math-dynamic-positioning-with-trigonometry-2co6</guid>
      <description>&lt;p&gt;When I needed to pass Calculus and Algebra during my Computer Science degree, I used the formula known to every Polish student called 'ZZZ' (Zakuć, Zdać, Zapomnieć) - Cram, Pass, Forget. It means &lt;em&gt;memorizing just enough to pass the exam and then not caring if you'll remember any of it later&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Fast forward a few years into my web developer career and I needed to implement a &lt;code&gt;mouseMove&lt;/code&gt; event on the SVG element. Every move I made with my mouse made the element's position shoot off into the void. I solved this issue using the transformation matrix. &lt;/p&gt;

&lt;p&gt;The more I worked with SVGs and graphs, the more I realized that the math I tried to cram and forget shows up in everything that I do. From the coordinates to graph layouts, drag-and-drop to animations - we just don't call it 'math'. &lt;/p&gt;

&lt;p&gt;This series attempts to show you that math. Each article takes one concept (that we had to cram in class) and shows exactly where it lives in real frontend code, with real examples I've built in production or in side projects. I don't want to show you mathematical proofs, I will explain a bit of theory with a demonstration how to use it when &lt;strong&gt;you&lt;/strong&gt; are the one who has to position elements just the right way, resolve conflicts and overlaps or draw a line from one point to another.&lt;/p&gt;

&lt;p&gt;Welcome to &lt;strong&gt;Know Your WebDev Math&lt;/strong&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Part 1: Dynamic positioning with trigonometry
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;I play a ton of DnD. And in my longest and favourite campaign (Curse of Strahd) the relations within the party and between the party and important NPCs (Ireena) are extremely important. We keep an Excel spreadsheet describing the current relationship status (from 'love' to 'hate' to 'it's complicated'). And I had an idea of creating an interactive diagram of those relations.&lt;/p&gt;

&lt;h3&gt;
  
  
  Requirements
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Every character avatar and name needs to be visible. &lt;/li&gt;
&lt;li&gt;Every character needs to be connected to every other character.&lt;/li&gt;
&lt;li&gt;The color of the connection symbolizes the relationship status.&lt;/li&gt;
&lt;li&gt;Hovering over a character's avatar should show description of what they think of others and what others think of them.&lt;/li&gt;
&lt;li&gt;The number of characters is not fixed.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Analysis
&lt;/h3&gt;

&lt;p&gt;Graph is the best structure to show elements and their relations, so I decided to implement my diagram in React Flow.&lt;br&gt;
To ensure good readability of the graph I decided to use circular graph layout:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F41j9ho1fl8yu7q59v9rn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F41j9ho1fl8yu7q59v9rn.png" alt="Circular graph layout" width="321" height="321"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It means that each character avatar should be positioned on the edge of the circle.&lt;br&gt;
Only one question remained: &lt;strong&gt;How to dynamically position elements in the circle?&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Solution: Trigonometry
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Theory: sine and cosine
&lt;/h3&gt;

&lt;p&gt;This is a right-angled triangle.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs1n6ei77ycftsv83bdbh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs1n6ei77ycftsv83bdbh.png" alt="Right angled triangle" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(Bear with me for a moment, I know you know what a triangle is. All of this will matter in a second)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;It has 3 sides: opposite, adjacent and hypotenuse. It also has an acute angle, let's call this angle α.&lt;/p&gt;

&lt;p&gt;We can calculate sine of α - sin(α) - by dividing the length of the opposite side by the length of hypotenuse side: &lt;code&gt;sin(α) = opposite / hypotenuse&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Same with cosine of α - cos(α) - we need to divide the length of the adjacent side by the length of the hypotenuse side: &lt;code&gt;cos(α) = adjacent / hypotenuse&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Sine and cosine are ratios, which means they stay exactly the same for every specific angle value. The sine of 30 degree angle is always 0.5 - it doesn't matter if the opposite side of a triangle has a length of 2 or 200.&lt;/p&gt;
&lt;h3&gt;
  
  
  How is it going to help us?
&lt;/h3&gt;

&lt;p&gt;We want to position elements on the edge of the circle in equal distances from each other - we need to calculate x and y position of the centre of each element.&lt;/p&gt;

&lt;p&gt;Let's go back to our circular graph. If we draw the line from the centre of the graph to the centre of one of the nodes, we can create a right-angled triangle in which the lengths of adjacent and opposite sides are our x and y, respectively.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqib6qzcu9hpr9nrer9xn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqib6qzcu9hpr9nrer9xn.png" alt="Circular graph layout with a triangle" width="321" height="321"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We need to find the lengths of sides in our triangle. And we can do that using sine and cosine.&lt;/p&gt;
&lt;h3&gt;
  
  
  Calculations
&lt;/h3&gt;

&lt;p&gt;The easiest side is hypotenuse - it's the radius of our layout circle, let's call this variable &lt;code&gt;radius&lt;/code&gt;. It can be arbitrary, just adjust it to the size of your nodes. &lt;br&gt;
The center of the graph (point &lt;code&gt;C&lt;/code&gt;) can also be arbitrary, let's assume variable &lt;code&gt;c&lt;/code&gt; of type &lt;code&gt;Point&lt;/code&gt;: &lt;code&gt;type Point = {x: number; y: number}&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To calculate the value of x - adjuscent side of triangle - let's change the cosine equation: &lt;br&gt;
&lt;code&gt;adjacent = cos(α) * hypotenuse&lt;/code&gt;.&lt;br&gt;
And to calculate the value of y - opposite side - let's change the sine equation the same way:&lt;br&gt;
&lt;code&gt;opposite = sin(α) * hypotenuse&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;We can calculate the sine and cosine values for specific angle α using functions from JavaScript Math library: &lt;code&gt;Math.sin&lt;/code&gt; and &lt;code&gt;Math.cos&lt;/code&gt;. Those functions take radian angle value as parameter. &lt;/p&gt;
&lt;h4&gt;
  
  
  So how can we calculate radian value of α?
&lt;/h4&gt;

&lt;p&gt;We know that our graph is going to have &lt;code&gt;n&lt;/code&gt; elements. And radian value of 360 degree angle is 2π.&lt;/p&gt;

&lt;p&gt;So our α is: &lt;code&gt;α = 2π / n&lt;/code&gt; or in JS: &lt;code&gt;const alpha = (2 * Math.PI) / n&lt;/code&gt;.&lt;/p&gt;
&lt;h4&gt;
  
  
  Final calculation
&lt;/h4&gt;

&lt;p&gt;Now, we need to iterate over each node and calculate its position (adjusting for center point &lt;code&gt;c&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;updatedNodes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;nodes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;node&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;angle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;alpha&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;node&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="na"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;radius&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cos&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;angle&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="na"&gt;y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;y&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;radius&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;angle&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
          &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="p"&gt;};&lt;/span&gt;
     &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nodes above are graph nodes from React Flow, so if I'll set &lt;code&gt;position&lt;/code&gt; property in the node object, React Flow will automatically place them for me. &lt;/p&gt;

&lt;h2&gt;
  
  
  Result
&lt;/h2&gt;

&lt;p&gt;Behold, an example with Baldur's Gate 3 characters!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3trijhxa9crzvlnvklyc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3trijhxa9crzvlnvklyc.png" alt="Example" width="800" height="594"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Additionally, you can adjust your &lt;code&gt;radius&lt;/code&gt; variable based on the number of nodes in the graph to have fully dynamic graph, growing with the number of characters you want to have in your D&amp;amp;D (or DaggerHeart, or Call of Cthulhu or any other system) session. &lt;/p&gt;

&lt;p&gt;I decided to start &lt;strong&gt;Know Your WebDev Math&lt;/strong&gt; series with simple trigonometry, because sine and cosine are, for me, the symbols of 'that stupid math I won't ever use in my life' approach. Turns out, trigonometry was just waiting for me to build something worthy using it on.&lt;/p&gt;

&lt;p&gt;If you play D&amp;amp;D or have a graph layout problem, drop it in the comments!&lt;/p&gt;

&lt;p&gt;Next up: the tower of Babel of different coordinate systems, and how transformation matrix acts as a translator.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>reactflow</category>
      <category>react</category>
    </item>
    <item>
      <title>Create elegant OpenAPI spec documentation with Rapi Doc and Vitepress</title>
      <dc:creator>Ola B</dc:creator>
      <pubDate>Sat, 23 Nov 2024 17:32:44 +0000</pubDate>
      <link>https://dev.to/vakme/create-elegant-openapi-spec-documentation-with-rapi-doc-and-vitepress-21pk</link>
      <guid>https://dev.to/vakme/create-elegant-openapi-spec-documentation-with-rapi-doc-and-vitepress-21pk</guid>
      <description>&lt;p&gt;I recently had to create a documentation page supporting OpenAPI spec documentation. What's an OpenAPI spec documentation? A page, either self-hosted or included in your API management platform, that allows users to check what endpoints, methods, webhooks, etc., are available based on OpenAPI JSON or YAML.&lt;/p&gt;

&lt;p&gt;I needed to find a balance between needing as many customization options as possible and using ready-to-go tools for quick setup and deployment.&lt;/p&gt;

&lt;p&gt;And I found &lt;a href="https://rapidocweb.com/index.html" rel="noopener noreferrer"&gt;Rapi Doc&lt;/a&gt; - a web component that can be embedded anywhere.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxdkus496pfeb1ppbxiaj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxdkus496pfeb1ppbxiaj.png" alt=" " width="800" height="531"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the component ready, I needed a tool to write documentation that supported custom components.&lt;/p&gt;

&lt;p&gt;So I chose &lt;a href="https://vitepress.dev/" rel="noopener noreferrer"&gt;Vitepress&lt;/a&gt;. And I had two tools that I wanted to merge. How did it go? Let's find out.&lt;/p&gt;

&lt;h2&gt;
  
  
  Running app in dev mode
&lt;/h2&gt;

&lt;p&gt;I'll skip the story of Vitepress setup - you can find the instructions on their main page.&lt;/p&gt;

&lt;p&gt;I also created a custom RapiDoc.vue component where I embedded my &lt;code&gt;rapi-doc&lt;/code&gt; web component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt; &lt;span class="na"&gt;setup&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;rapidoc&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;rapi-doc&lt;/span&gt;
      &lt;span class="na"&gt;spec-url = &lt;/span&gt;&lt;span class="s"&gt;"https://petstore.swagger.io/v2/swagger.json"&lt;/span&gt;
      &lt;span class="na"&gt;render-style = &lt;/span&gt;&lt;span class="s"&gt;"read"&lt;/span&gt;
      &lt;span class="na"&gt;style = &lt;/span&gt;&lt;span class="s"&gt;"height:100vh; width:100%"&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;&amp;lt;/rapi-doc&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;style&lt;/span&gt; &lt;span class="na"&gt;scoped&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;style&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I also embedded this custom component in a &lt;code&gt;api-docs.md&lt;/code&gt; page &lt;em&gt;(yes, you can embed Vue Components in Markdown, I love Vitepress for it!)&lt;/em&gt; so I could see it in my Vitepress documentation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;---
sidebar: false
layout: page
---

&amp;lt;script setup&amp;gt;
import RapiDoc from './components/RapiDoc.vue';
&amp;lt;/script&amp;gt;

&amp;lt;RapiDoc /&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I ran &lt;code&gt;yarn docs:dev&lt;/code&gt; expecting everything to go smoothly (I followed the instructions from both documentations, so it should be fine, right?)...&lt;/p&gt;

&lt;p&gt;And I got this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fshlu28gc8y9yh90fnbwb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fshlu28gc8y9yh90fnbwb.png" alt="Start infinite loop" width="800" height="511"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And my browser froze.&lt;/p&gt;

&lt;p&gt;Woohoo, long live the infinite loop!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What happened?&lt;/strong&gt; So, since &lt;code&gt;rapi-doc&lt;/code&gt; is a web component, I need to explicitly tell Vue compiler to not parse it. To just leave it alone.&lt;/p&gt;

&lt;p&gt;And inside my &lt;code&gt;config.mts&lt;/code&gt; file I needed to add:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;defineConfig&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vitepress&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="c1"&gt;// https://vitepress.dev/reference/site-config&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nf"&gt;defineConfig&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="p"&gt;...&lt;/span&gt;
  &lt;span class="na"&gt;vue&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;compilerOptions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;isCustomElement&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;tag&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;tag&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;indexOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;rapi-doc&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We just need to check for custom elements and inform Vue "hey, this tag is off-limits".&lt;/p&gt;

&lt;p&gt;So, we have it, it runs!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu0u0o68fmsqcl17ld4y2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu0u0o68fmsqcl17ld4y2.png" alt="App in dev mode" width="800" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And then I tried to build it so I could set up deployment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building the app
&lt;/h2&gt;

&lt;p&gt;I ran &lt;code&gt;yarn docs:build&lt;/code&gt; command. And I immediately (&lt;em&gt;wow, Vite, you're quick!&lt;/em&gt;) got this error:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbaj3mardxolmdih66mbn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbaj3mardxolmdih66mbn.png" alt="Vite build error" width="472" height="111"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This error means that during build-time, Vite couldn't access a &lt;code&gt;self&lt;/code&gt; property. This can also happen if you try to access browser API (e.g., window) from server (in Nuxt or any other SSR framework, for example).&lt;/p&gt;

&lt;p&gt;So what we can do? We can import it dynamically in runtime!&lt;/p&gt;

&lt;p&gt;Let's change our import from this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt; &lt;span class="na"&gt;setup&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;rapidoc&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt; &lt;span class="na"&gt;setup&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;onMounted&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vue&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;onMounted&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;rapidoc&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And now build should pass with no issues! Enjoy you API spec docs!&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus: Dark Mode
&lt;/h2&gt;

&lt;p&gt;Vitepress comes with dark mode, working out-of-the-box. But how can we make our RapiDoc documentation reacting to mode changes?&lt;/p&gt;

&lt;p&gt;We can use Vitepress core composable - &lt;code&gt;useData&lt;/code&gt;. It contains &lt;code&gt;isDark&lt;/code&gt; property with information if the darkmode is enabled or not.&lt;/p&gt;

&lt;p&gt;So let's use it inside the script section in the SFC:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt; &lt;span class="na"&gt;setup&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useData&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vitepress&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ref&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vue&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useData&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;theme&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isDark&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dark&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;light&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now when we have a &lt;code&gt;theme&lt;/code&gt; ref, we can pass it to the &lt;code&gt;rapi-doc&lt;/code&gt; Web Component via attribute binding:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;rapi-doc&lt;/span&gt;
      &lt;span class="na"&gt;spec-url = &lt;/span&gt;&lt;span class="s"&gt;"https://petstore.swagger.io/v2/swagger.json"&lt;/span&gt;
      &lt;span class="na"&gt;render-style = &lt;/span&gt;&lt;span class="s"&gt;"read"&lt;/span&gt;
      &lt;span class="na"&gt;:theme=&lt;/span&gt;&lt;span class="s"&gt;"theme"&lt;/span&gt;
      &lt;span class="na"&gt;style = &lt;/span&gt;&lt;span class="s"&gt;"height:100vh; width:100%"&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;&amp;lt;/rapi-doc&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We need to add one more thing for dark mode to work correctly - responding to theme change.&lt;/p&gt;

&lt;p&gt;Let's add a watcher to our &lt;code&gt;script&lt;/code&gt; section:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nf"&gt;watch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isDark&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;isDark&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;isDark&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dark&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;light&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And voila, you created API docs that react to theme changes!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0swhnmb9i1rz4snacyjv.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0swhnmb9i1rz4snacyjv.gif" alt=" " width="760" height="380"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>vue</category>
      <category>webcomponents</category>
    </item>
    <item>
      <title>Animate your SVG text with animejs (and Vue)</title>
      <dc:creator>Ola B</dc:creator>
      <pubDate>Thu, 18 May 2023 21:56:07 +0000</pubDate>
      <link>https://dev.to/vakme/animate-your-svg-text-with-animejs-64p</link>
      <guid>https://dev.to/vakme/animate-your-svg-text-with-animejs-64p</guid>
      <description>&lt;p&gt;Are you looking for a non-standard portfolio page welcome text? Do you want to create an animated website to propose to your loved one? &lt;/p&gt;

&lt;p&gt;Say no more!&lt;/p&gt;

&lt;p&gt;In this #showdev I'll teach you how to create stunning SVG animation with an equally stunning &lt;code&gt;animejs&lt;/code&gt; library!&lt;/p&gt;

&lt;p&gt;The result will look like this: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fvakme.github.io%2Fhowdy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fvakme.github.io%2Fhowdy.gif" alt="Gif of result" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;NOTE: This post will show you how to create a line drawing animation in animejs. If you want it in a condensed form, straight from the source, visit &lt;a href="https://animejs.com/documentation/#lineDrawing" rel="noopener noreferrer"&gt;the official documentation&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;To create a stunning animated SVG image, first, you will need SVG to animate. There are many tools to do that, available both online and offline. You can, for example, start with generating text using &lt;a href="https://github.com/kartsims/easysvg" rel="noopener noreferrer"&gt;easysvg&lt;/a&gt; (written in php, but a great tool nonetheless). &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Important: Every letter in your SVG should be a separate &lt;code&gt;&amp;lt;path&amp;gt;&lt;/code&gt; tag! Here paths mark the outlines of the letters.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You will also need a container to run the animation in. It can be anything, pure JS script or a more advanced app. In my case, I'm using a very simple Vue.js app.&lt;/p&gt;

&lt;h2&gt;
  
  
  Preparing your SVG
&lt;/h2&gt;

&lt;p&gt;To make our SVG look classy, we need to tweak it a bit: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;To provide it with an "outlined" look, set &lt;code&gt;fill&lt;/code&gt; attribute in every &lt;code&gt;&amp;lt;path&amp;gt;&lt;/code&gt; tag to &lt;code&gt;transparent&lt;/code&gt; and set &lt;code&gt;stroke&lt;/code&gt; attribute to any color you want.&lt;/li&gt;
&lt;li&gt;Add some extra elements for flavor - directly in SVG code (if you're the pro and a math nerd) or use some editor to do it.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;Use my SVG, if you want: &lt;a href="https://github.com/Vakme/vakme.github.io/blob/main/src/assets/howdy.svg" rel="noopener noreferrer"&gt;link to github file&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Animating
&lt;/h2&gt;

&lt;p&gt;First, install &lt;code&gt;animejs&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fassets.dev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/juliangarnier" rel="noopener noreferrer"&gt;
        juliangarnier
      &lt;/a&gt; / &lt;a href="https://github.com/juliangarnier/anime" rel="noopener noreferrer"&gt;
        anime
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      JavaScript animation engine
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Anime.js&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;
  
    
    &lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fjuliangarnier%2Fanime%2F.%2Fassets%2Fimages%2Fanimejs-v4-logo-animation.gif" class="article-body-image-wrapper"&gt;&lt;img alt="Anime.js V4 logo animation" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fjuliangarnier%2Fanime%2F.%2Fassets%2Fimages%2Fanimejs-v4-logo-animation.gif" width="560"&gt;&lt;/a&gt;
  
&lt;/p&gt;

&lt;p&gt;
  &lt;strong&gt;
  &lt;em&gt;Anime.js&lt;/em&gt; is a fast, multipurpose and lightweight JavaScript animation library with a simple, yet powerful API.&lt;br&gt;
  It works with CSS properties, SVG, DOM attributes and JavaScript Objects
  &lt;/strong&gt;
&lt;/p&gt;

&lt;p&gt;
  &lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/7b364eaced6898c1ce124242f4fff52f80c98f1228257031f4ca5202663fd558/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f646d2f616e696d656a733f7374796c653d666c61742d737175617265266c6f676f3d6e706d"&gt;&lt;img alt="NPM Downloads" src="https://camo.githubusercontent.com/7b364eaced6898c1ce124242f4fff52f80c98f1228257031f4ca5202663fd558/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f646d2f616e696d656a733f7374796c653d666c61742d737175617265266c6f676f3d6e706d"&gt;&lt;/a&gt;
  &lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/b5148e620e83ea2448dd1a4ca2b77c83816bcdaebf4b7b28011b9a5a4c186858/68747470733a2f2f696d672e736869656c64732e696f2f6a7364656c6976722f6e706d2f686d2f616e696d656a733f7374796c653d666c61742d737175617265266c6f676f3d6a7364656c69766572"&gt;&lt;img alt="jsDelivr hits (npm)" src="https://camo.githubusercontent.com/b5148e620e83ea2448dd1a4ca2b77c83816bcdaebf4b7b28011b9a5a4c186858/68747470733a2f2f696d672e736869656c64732e696f2f6a7364656c6976722f6e706d2f686d2f616e696d656a733f7374796c653d666c61742d737175617265266c6f676f3d6a7364656c69766572"&gt;&lt;/a&gt;
  &lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/430c32e279f3c06ce8715ab9f975e7f230c61f6d05a19fcf634276aeaceee4cd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73706f6e736f72732f6a756c69616e6761726e6965723f7374796c653d666c61742d737175617265266c6f676f3d676974687562"&gt;&lt;img alt="GitHub Sponsors" src="https://camo.githubusercontent.com/430c32e279f3c06ce8715ab9f975e7f230c61f6d05a19fcf634276aeaceee4cd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73706f6e736f72732f6a756c69616e6761726e6965723f7374796c653d666c61742d737175617265266c6f676f3d676974687562"&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Sponsors&lt;/h2&gt;
&lt;/div&gt;

&lt;p&gt;Anime.js is 100% free and is only made possible with the help of our sponsors.
Help the project become sustainable by sponsoring us on &lt;a href="https://github.com/sponsors/juliangarnier" rel="noopener noreferrer"&gt;GitHub Sponsors&lt;/a&gt;.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;Platinum sponsors&lt;/h3&gt;

&lt;/div&gt;
&lt;p&gt;
&lt;a href="https://ice.io/?ref=animejs" rel="nofollow noopener noreferrer"&gt;
  
    
    &lt;/a&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fjuliangarnier%2Fanime%2F.%2Fassets%2Fsponsors%2Fice-open-network-logomark-dark.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fjuliangarnier%2Fanime%2F.%2Fassets%2Fsponsors%2Fice-open-network-logomark-dark.png" width="250"&gt;&lt;/a&gt;
  

&lt;a href="https://go.warp.dev/anime" rel="nofollow noopener noreferrer"&gt;
  
    
    &lt;/a&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fjuliangarnier%2Fanime%2F.%2Fassets%2Fsponsors%2Fwarp-logomark-dark.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fjuliangarnier%2Fanime%2F.%2Fassets%2Fsponsors%2Fwarp-logomark-dark.png" width="250"&gt;&lt;/a&gt;
  

&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;Silver sponsors&lt;/h3&gt;

&lt;/div&gt;

&lt;p&gt;
&lt;a href="https://www.lambdatest.com?utm_source=animeJS&amp;amp;utm_medium=organic&amp;amp;utm_campaign=july_08&amp;amp;utm_term=sk&amp;amp;utm_content=opensource" rel="nofollow noopener noreferrer"&gt;
  
    
    &lt;/a&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fjuliangarnier%2Fanime%2F.%2Fassets%2Fsponsors%2Flambdatest-logomark-dark.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fjuliangarnier%2Fanime%2F.%2Fassets%2Fsponsors%2Flambdatest-logomark-dark.png" width="150"&gt;&lt;/a&gt;
  

&lt;a href="https://inspatialapp.com/?ref=animejs" rel="nofollow noopener noreferrer"&gt;
  
    
    &lt;/a&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fjuliangarnier%2Fanime%2F.%2Fassets%2Fsponsors%2Finspatial-logomark-dark.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fjuliangarnier%2Fanime%2F.%2Fassets%2Fsponsors%2Finspatial-logomark-dark.png" width="150"&gt;&lt;/a&gt;
  

&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Usage&lt;/h2&gt;

&lt;/div&gt;

&lt;p&gt;Anime.js V4 works by importing ES modules like so:&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;div class="table-wrapper-paragraph"&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;table&gt;

&lt;tbody&gt;

&lt;tr&gt;

  &lt;td&gt;

&lt;div class="highlight highlight-source-js notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-k"&gt;import&lt;/span&gt; &lt;span class="pl-kos"&gt;{&lt;/span&gt;
  &lt;span class="pl-s1"&gt;animate&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt;
  &lt;span class="pl-s1"&gt;stagger&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt;
&lt;span class="pl-kos"&gt;}&lt;/span&gt; &lt;span class="pl-k"&gt;from&lt;/span&gt; &lt;span class="pl-s"&gt;'animejs'&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;

&lt;span class="pl-en"&gt;animate&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-s"&gt;'.square'&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt; &lt;span class="pl-kos"&gt;{&lt;/span&gt;
  &lt;span class="pl-c1"&gt;x&lt;/span&gt;: &lt;span class="pl-c1"&gt;320&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt;
  &lt;span class="pl-c1"&gt;rotate&lt;/span&gt;: &lt;span class="pl-kos"&gt;{&lt;/span&gt; &lt;span class="pl-c1"&gt;from&lt;/span&gt;: &lt;span class="pl-c1"&gt;-&lt;/span&gt;&lt;span class="pl-c1"&gt;180&lt;/span&gt; &lt;span class="pl-kos"&gt;}&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt;
  &lt;span class="pl-c1"&gt;duration&lt;/span&gt;: &lt;span class="pl-c1"&gt;1250&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt;
  &lt;span class="pl-c1"&gt;delay&lt;/span&gt;: &lt;span class="pl-en"&gt;stagger&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-c1"&gt;65&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt; &lt;span class="pl-kos"&gt;{&lt;/span&gt; &lt;span class="pl-c1"&gt;from&lt;/span&gt;: &lt;span class="pl-s"&gt;'center'&lt;/span&gt; &lt;span class="pl-kos"&gt;}&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt;
  &lt;span class="pl-c1"&gt;ease&lt;/span&gt;: &lt;span class="pl-s"&gt;'inOutQuint'&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt;
  &lt;span class="pl-c1"&gt;loop&lt;/span&gt;: &lt;span class="pl-c1"&gt;true&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt;
  &lt;span class="pl-c1"&gt;alternate&lt;/span&gt;: &lt;span class="pl-c1"&gt;true&lt;/span&gt;
&lt;span class="pl-kos"&gt;}&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
  &lt;/td&gt;
  &lt;td&gt;
    &lt;a rel="noopener noreferrer" href="https://github.com/juliangarnier/anime/./assets/images/usage-example-result.gif"&gt;&lt;img alt="Anime.js code example" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fjuliangarnier%2Fanime%2F.%2Fassets%2Fimages%2Fusage-example-result.gif"&gt;&lt;/a&gt;
  &lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;V4 Documentation&lt;/h2&gt;

&lt;/div&gt;

&lt;p&gt;The full documentation is available &lt;a href="https://animejs.com/documentation" rel="nofollow noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;V3 Migration guide&lt;/h2&gt;

&lt;/div&gt;

&lt;p&gt;You can find the v3 to v4 migration guide…&lt;/p&gt;&lt;/div&gt;


&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/juliangarnier/anime" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


&lt;p&gt;Then add animejs animation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;anime&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;targets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementsByTagName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;svg&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;strokeDashoffset&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;anime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setDashoffset&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="na"&gt;easing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;easeInOutBack&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;250&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;direction&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;normal&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Easy? Let me break it down line by line!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;    &lt;span class="nx"&gt;targets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementsByTagName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;svg&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this line, we point to every element we want to animate, in this case to an array of every child element of our SVG. You may need to adjust it a little to the structure of your SVG.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;    &lt;span class="nx"&gt;strokeDashoffset&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;anime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setDashoffset&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is what makes animation happen. It uses &lt;code&gt;stroke-dashoffset&lt;/code&gt; attribute. If you want to know more about animating SVGs using this attribute, I recommend &lt;a href="https://css-tricks.com/svg-line-animation-works/" rel="noopener noreferrer"&gt;this CSS Tricks article&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;    &lt;span class="nx"&gt;easing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;easeInOutBack&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I wanted to add a little "bouncing" at the beginning and the end of the animation of every letter. If you want to test different easing functions on your own, I recommend &lt;a href="https://easings.net/" rel="noopener noreferrer"&gt;easings.net&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;    &lt;span class="nx"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;250&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I wanted to slightly delay every animated path, so I passed a function that multiplies the delay by the index of an element in the table I passed in &lt;code&gt;targets&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;    &lt;span class="nx"&gt;direction&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;normal&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can choose from &lt;code&gt;normal&lt;/code&gt;, &lt;code&gt;reverse&lt;/code&gt;, and &lt;code&gt;alternate&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Embed this... somewhere
&lt;/h2&gt;

&lt;p&gt;Although animejs can be used in Vanilla, I really wanted to use it in my Vue.js app.&lt;/p&gt;

&lt;p&gt;I used Vue.js transitions to do that. &lt;a href="https://vuejs.org/guide/built-ins/transition.html" rel="noopener noreferrer"&gt;More on them.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First, template:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;Transition&lt;/span&gt; &lt;span class="na"&gt;appear&lt;/span&gt; &lt;span class="na"&gt;:css=&lt;/span&gt;&lt;span class="s"&gt;"false"&lt;/span&gt; &lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="na"&gt;enter=&lt;/span&gt;&lt;span class="s"&gt;"onEnter"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"howdy"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="c"&gt;&amp;lt;!-- Your SVG goes here. I used v-html because I'm lazy ¯\_(ツ)_/¯  --&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;v-html=&lt;/span&gt;&lt;span class="s"&gt;"howdy"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/Transition&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;You can use &lt;a href="https://blog.logrocket.com/using-svg-and-vue-js-a-complete-guide/" rel="noopener noreferrer"&gt;SVG Component&lt;/a&gt; to embed your SVG on a page.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I wanted my animation to start on a component render, so I added &lt;code&gt;appear&lt;/code&gt; keyword to the transitions. I also needed to tell Vue this animation would be purely JS, so I used &lt;code&gt;:css="false"&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Now I only need to write &lt;code&gt;onEnter&lt;/code&gt; callback:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;onEnter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Element&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;done&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;anime&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;targets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementsByTagName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;svg&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;strokeDashoffset&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;anime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setDashoffset&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="na"&gt;easing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;easeInOutBack&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;250&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;direction&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;normal&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;complete&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;done&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;onEnter&lt;/code&gt; uses the Transition Element as the first argument and &lt;code&gt;done()&lt;/code&gt; function as the second. We have to call &lt;code&gt;done()&lt;/code&gt; function at the end of the application to signal to Vue that the animation ended. We can use &lt;code&gt;complete&lt;/code&gt; hook from animejs to do it.&lt;br&gt;
And we want to animate only descendants of our Transition element, so we can specify &lt;code&gt;targets&lt;/code&gt; using the first argument.&lt;/p&gt;

&lt;p&gt;And... that's it! Sit back and enjoy your animated text!&lt;/p&gt;

&lt;p&gt;If you have any questions, I'm happy to answer :) If there's anything to be improved in this short post, let me know, and I'll gladly fix that!&lt;/p&gt;

&lt;p&gt;And if you want to see this animation in action, you can visit &lt;a href="https://vakme.github.io/" rel="noopener noreferrer"&gt;my page&lt;/a&gt; (I have to warn you though, this is still in a WIP stage).&lt;/p&gt;

&lt;p&gt;All the best,&lt;/p&gt;

&lt;p&gt;Aleksandra (or Ola, for short)&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>animejs</category>
      <category>showdev</category>
      <category>vue</category>
    </item>
  </channel>
</rss>
